retreiving names cell values in VB

dcanham

Active Member
Joined
Jun 7, 2006
Messages
306
I'm having trouble retreiving the value from a named cell on another sheet in the same workbook in VB.

ex:
Workbook name = "Test"
Sheet1 has cell named "INV"
Sheet2 has a macro that needs to retreive the value from the named cell in Sheet1.

** here is the line of code
n_Amount = Workbooks("Test").Worksheets("Sheet1").Cells(Range("[Test]Sheet1!INV").Row, Range("[Test]Sheet1!INV").Column)

** here is the error message I'm getting
run time error '1004' method 'range of object _worksheet' failed

I'm thinking this means it can't find the thing I'm indicating? I don't know why? Similar code works for other value calls?

My question is twofold
1) Why would this line be throwing this error?
2) Is there a better way in VB to retreive a value from a named cell on another sheet??

Thanks in advance for any help.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
sorry, didn't mean to start such contraversy! :)
this is good to let our skills and knowledge grow
it's still a mistery why you can't run the line and also what you wanted to do with it, but I presume you were able to get a solution out of these posts

greetings,
Erik
 
Upvote 0
yes thanks....I used sunnyland's

n_amount=Workbooks("Test").Names("inv").RefersToRange.Value

suggestion, and it works well
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,592
Members
449,089
Latest member
Motoracer88

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