1004 Error Setting Variable Equal to Value of a Range

stinkingcedar

New Member
Joined
May 2, 2016
Messages
23
Hey guys,

So I keep getting a 1004 on this particular line of code

Code:
newVal = sht.Range(Cells(4 + (30 * i), j)).Value

Sht is a worksheet variable set to one specific sheet in the workbook, newVal has been declared as double, i and j have both been declared as integers. Keeps telling me the range method failed.
 
Is there a value in cell E4 of shtD? If so, what is it?
 
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Oops, I was just looking at the code in the first post.:eek:
 
Upvote 0
Oops, I was just looking at the code in the first post.:eek:

Don't know why I didn't see it right away. I normally spot those right off. A lot people make the mistake of using Range to precede a Cells desination. That should fix the problem for the OP.
 
Last edited:
Upvote 0
Don't know why I didn't see it right away. I normally spot those right off. A lot people make the mistake of using Range to precede a Cells desination. That should fix the problem for the OP.
I missed it too. :cry:
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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