copying between worksheets

kluitna

Board Regular
Joined
Mar 10, 2002
Messages
75
Have some code that I can't get to work. Its from copying from a series of worksheets in a workbook to a summary worksheet in teh same workbook.

The code goes as follows:

Sub Summary()
Dim Itemnum As String
For i = 2 To 500
Itemnum = Worksheets(1).Cells(i, 2)
If Itemnum = blank Then End
Sheets(1 + i).Select
Range("c9").Select
Selection.Copy
Sheets("Summary").Cells(2 + i, 1).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Next i
End Sub

when I runit I have problems with the line
sheets("summary").cells(2+i, 1).select
I can't figuge out why teh compiler is hanging here, I have used similar code on other sheets but instead of sheets I used worksheets instead of sheets. I also tried worksheets in place of sheets and it still did not work.
Anyone out there have any suggestions?
any help would be greatly appreciated
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
select the sheet first. It needs the sheet to be active.

so, before selecting the cell enter:
Sheets("Summary").Activate

btw, so that you don't see all this, you could add an Application.ScreenUpdating = False
to the beginning of your code.
It'll run faster - esp. with the switching between sheets.
 
Upvote 0

Forum statistics

Threads
1,226,504
Messages
6,191,428
Members
453,657
Latest member
DukeJester

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top