Simple Worksheet.Range issue

JimmyMack

New Member
Joined
May 18, 2012
Messages
11
I keep getting a "method 'range' of object '_worksheet' failed" error when I reach the line in red. Ideas?


Sub UpdateMasterSheet()
'
' UpdateMasterSheet Macro
' Updates master worksheet from individual staff sheets
'
' Keyboard Shortcut: Ctrl+Shift+U
'
Dim MasterSheet As Worksheet
Dim iStaff As Integer, iRow As Integer
Dim StaffName As Variant
Dim iCell As Range

Set MasterSheet = Sheets("May- July 2012")

For i = 0 To 13
iStaff = i
iRow = (i + 1) * 3
StaffName = Array("Rochelle", "Cassie", "Bryan", "Rich", "Bill", "Kelly", _
"Steve", "Garrett", "Ena", "Cindy", "Matt", "John", "New Person", _
"Brent Waters")

Sheets(StaffName(iStaff)).Select
Range("D3:GZ4").Copy
MasterSheet.Select
MasterSheet.Range(Cells(iRow, 4)).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, _
SkipBlanks:= False, Transpose:=False
Next i
End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Resolved: Simple Worksheet.Range issue

Worked around the issue using this code:

Sub UpdateMasterSheet()
'
' UpdateMasterSheet Macro
' Updates master worksheet from individual staff sheets
'
' Keyboard Shortcut: Ctrl+Shift+U
'
Dim MasterSheet As Worksheet
Dim iStaff As Integer, iRow As Integer
Dim StaffName As Variant
Dim iCell As Range

Set MasterSheet = Sheets("May- July 2012")

For i = 0 To 13
iStaff = i
iRow = (i + 1) * 3
StaffName = Array("Rochelle", "Cassie", "Bryan", "Rich", "Bill", "Kelly", _
"Steve", "Garrett", "Ena", "Cindy", "Matt", "John", "New Person", _
"Brent Waters")

Sheets(StaffName(iStaff)).Select
Range("D3:GZ4").Copy
MasterSheet.Select
Cells(iRow, 4).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, _
SkipBlanks:= False, Transpose:=False
Next i
End Sub



I'd still like to know why the original didn't work, though, if anyone has a minute
 
Upvote 0

Forum statistics

Threads
1,215,603
Messages
6,125,771
Members
449,259
Latest member
rehanahmadawan

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