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

mmann1973

New Member
Joined
Oct 11, 2013
Messages
44
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
 

Some videos you may like

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,388
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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)
 

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
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)
 

mmann1973

New Member
Joined
Oct 11, 2013
Messages
44
Sorry for not saying which row was throwing the error, you were correct in your choosing.

Your solution fixed my problem...Thank you!
 

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,388
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
You are welcome - thanks for the reply.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,914
Messages
5,598,840
Members
414,261
Latest member
KatieBsc

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
Top