LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default assining a varaible to the value in another sheet.

Is this code in a UDF? If not, it is unlikely that
Application.Caller.Parent.Parent will work.

Try this

nmodules = ThisWorkbook.Sheets("Sheet1").Range("NSETS").Value

if everything is in the same workbook

or even

nmodules = ActiveWorkbook.Sheets("Sheet1").Range("NSETS").Val ue

if you will use it on other workbooks, activating it before



--

HTH

RP
(remove nothere from the email address if mailing direct)


"shishi" wrote in message
oups.com...
Hi,

I have 2 sheets in a work book. In Sheet1 I have something like
Number of sets = 27. This number (27) falls into the D7 of sheet1. I
have defined a name NSETS to this cell with this kind of expression
=Sheet1!$D$7. But now I need to use this number in the vba code I have
for the Sheet2. In Sheet2 I have the code like this

Set WBook = Application.Caller.Parent.Parent
nmodules = WBook.Sheets("Sheet1").Range("NSETS").Value

But this is not working. What I am I doing wrong?

Thanks
shi



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlink varaible substitution - How To Sledge Bacon Excel Worksheet Functions 10 May 29th 08 06:03 PM
Use varaible for worsheet name in a formule slm Excel Programming 3 July 19th 05 12:34 PM
Assining the value of a vlookup to a cell rather than the vlookup dreastman Excel Programming 3 June 9th 05 10:16 PM
Disappearance of assigned value of varaible when working with form vbaprog Excel Programming 7 January 19th 05 11:39 PM
Passing a named varaible to Excel's Autofilter Jeff Glock Excel Programming 1 December 23rd 03 04:46 PM


All times are GMT +1. The time now is 12:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"