Need help: Run-time error '1004' in VBA code

mmann1973

New Member
Joined
Oct 11, 2013
Messages
46
I have been running this code successfully, for a while now. For some reason it just started throwing this error code:
Run-time error '1004':
Method 'Range' of object'_Global' failed


Sub New_Associate()
Dim NextRow As Range
Set NextRow = Range("A1" & Sheets("Helper").UsedRange.Rows.Count + 1)
Sheets("New Associate Entry").Range("C2:C7").Copy
Sheets("Helper").Activate
NextRow.PasteSpecial Paste:=xlValues, Transpose:=True
Application.CutCopyMode = False
Set NextRow = Nothing

End Sub


I'm not sure what's causing the error, any help in solving would be appreciated. Only thing I see that makes me wonder is, the page the data is stored on, just reached line 100.

I am running Excel 2016
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
You didn't tell us what line is highlighted when the error occurs so I'll assume it's this one:

Set NextRow = Range("A1" & Sheets("Helper").UsedRange.Rows.Count + 1)

which looks a bit strange. In effect, if you have say 100 rows in the used range of "Helper" then this sets NextRow equal to the cell: A1101
Is that really what you want? Maybe:

Set NextRow = Range("A" & Sheets("Helper").UsedRange.Rows.Count + 1)
 
Upvote 0
Code:
NextRow.PasteSpecial Paste:=xlValues, Transpose:=True

This cannot execute because the value of the 'NextRow' variable is invalid.

Change this
Code:
Set NextRow = Range("A1" & Sheets("Helper").UsedRange.Rows.Count + 1)
To This
Code:
Set NextRow = Range("A" & Sheets("Helper").UsedRange.Rows.Count + 1)
 
Upvote 0
Sorry for not saying which row was throwing the error, you were correct in your choosing.

Your solution fixed my problem...Thank you!
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,175
Members
452,615
Latest member
bogeys2birdies

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