PC Review


Reply
Thread Tools Rate Thread

Access Named range value with multiple workbooks open

 
 
ksgoodwin@gmail.com
Guest
Posts: n/a
 
      12th Dec 2006
I am trying to access the value in a single cell that is a named range.

Code:

If Workbooks(Current).Names("UpDate_File_Name1").Value = "Save to" then
....

When I debug the .Value I get the cell address not the cell value; in
this case:

=Setup!$C$3 instead of "Save to" which is the value in the cell.

I can do:

If Activeworkbook.Worksheets("Setup").cells(3,3).value = "Save to"
then...

or

If Workbooks(Current).Worksheets("Setup").Cells(3, 3).Value = "Save to"
then...

and get the Value to be: "Save to"

I would like to use Named ranges in the VBA code.

Ken

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sk1C?=
Guest
Posts: n/a
 
      13th Dec 2006
Perhaps
Workbooks(Current).Names("UpDate_File_Name1").RefersToRange.Value

or
Range("Update_File_Name1").Value


"(E-Mail Removed)" wrote:

> I am trying to access the value in a single cell that is a named range.
>
> Code:
>
> If Workbooks(Current).Names("UpDate_File_Name1").Value = "Save to" then
> ....
>
> When I debug the .Value I get the cell address not the cell value; in
> this case:
>
> =Setup!$C$3 instead of "Save to" which is the value in the cell.
>
> I can do:
>
> If Activeworkbook.Worksheets("Setup").cells(3,3).value = "Save to"
> then...
>
> or
>
> If Workbooks(Current).Worksheets("Setup").Cells(3, 3).Value = "Save to"
> then...
>
> and get the Value to be: "Save to"
>
> I would like to use Named ranges in the VBA code.
>
> Ken
>
>

 
Reply With Quote
 
=?Utf-8?B?Sk1C?=
Guest
Posts: n/a
 
      13th Dec 2006
This suggestion
> Range("Update_File_Name1").Value

I believe will only work if the workbook containing that named range is the
activeworkook.

It appears the worksheet containing the named range would also have to be
qualified if the named range is in a workbook that is not active:
Workbooks(current).Worksheets("Sheet1").Range("UpDate_File_Name1").Value

The RefersToRange may be a safer bet.

"JMB" wrote:

> Perhaps
> Workbooks(Current).Names("UpDate_File_Name1").RefersToRange.Value
>
> or
> Range("Update_File_Name1").Value
>
>
> "(E-Mail Removed)" wrote:
>
> > I am trying to access the value in a single cell that is a named range.
> >
> > Code:
> >
> > If Workbooks(Current).Names("UpDate_File_Name1").Value = "Save to" then
> > ....
> >
> > When I debug the .Value I get the cell address not the cell value; in
> > this case:
> >
> > =Setup!$C$3 instead of "Save to" which is the value in the cell.
> >
> > I can do:
> >
> > If Activeworkbook.Worksheets("Setup").cells(3,3).value = "Save to"
> > then...
> >
> > or
> >
> > If Workbooks(Current).Worksheets("Setup").Cells(3, 3).Value = "Save to"
> > then...
> >
> > and get the Value to be: "Save to"
> >
> > I would like to use Named ranges in the VBA code.
> >
> > Ken
> >
> >

 
Reply With Quote
 
ksgoodwin@gmail.com
Guest
Posts: n/a
 
      15th Dec 2006
It is true the .Range substitution for .Name alone does not work.
Error.

The Range("Update_File_Name1").Value has the problem with having to be
the active workbook. As stated. Works but not with another workbook
active.

The Workbooks(Current).Names("UpDate_File_Name1").RefersToRange.Value
works perfectly.

I don't need the Worksheets("Sheet1"). quantifyer but will add it if I
expand beyond my current needs.

All very helpful. Impressive.........

Thanks,

Ken


JMB wrote:
> This suggestion
> > Range("Update_File_Name1").Value

> I believe will only work if the workbook containing that named range is the
> activeworkook.
>
> It appears the worksheet containing the named range would also have to be
> qualified if the named range is in a workbook that is not active:
> Workbooks(current).Worksheets("Sheet1").Range("UpDate_File_Name1").Value
>
> The RefersToRange may be a safer bet.
>
> "JMB" wrote:
>
> > Perhaps
> > Workbooks(Current).Names("UpDate_File_Name1").RefersToRange.Value
> >
> > or
> > Range("Update_File_Name1").Value
> >
> >
> > "(E-Mail Removed)" wrote:
> >
> > > I am trying to access the value in a single cell that is a named range.
> > >
> > > Code:
> > >
> > > If Workbooks(Current).Names("UpDate_File_Name1").Value = "Save to" then
> > > ....
> > >
> > > When I debug the .Value I get the cell address not the cell value; in
> > > this case:
> > >
> > > =Setup!$C$3 instead of "Save to" which is the value in the cell.
> > >
> > > I can do:
> > >
> > > If Activeworkbook.Worksheets("Setup").cells(3,3).value = "Save to"
> > > then...
> > >
> > > or
> > >
> > > If Workbooks(Current).Worksheets("Setup").Cells(3, 3).Value = "Save to"
> > > then...
> > >
> > > and get the Value to be: "Save to"
> > >
> > > I would like to use Named ranges in the VBA code.
> > >
> > > Ken
> > >
> > >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Named Range: Same Names, Multiple Workbooks with Same Sheet Name BEEJAY Microsoft Excel Misc 4 7th Nov 2008 03:19 PM
renaming a Named Range in multiple workbooks Tagwim Microsoft Excel Programming 9 1st Jul 2008 04:22 PM
Strange named range issue with multiple workbooks =?Utf-8?B?QWRhbSBXaGl0ZQ==?= Microsoft Excel Misc 0 14th Nov 2006 02:34 AM
How do you point to a named range in linked workbooks? =?Utf-8?B?S0c=?= Microsoft Excel Misc 5 18th Feb 2005 09:55 PM
How to Link named ranges from multiple Workbooks into a single Wo. =?Utf-8?B?UE1BUF9IRUxQ?= Microsoft Excel Misc 1 14th Dec 2004 05:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:34 PM.