LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default "Set" statement with variables?

Is it possible to use variables in a "Set" statement?

For example, I have the following lines:

With Worksheets("Lookup")
Set General_kV = ("Lookup").Range("General_kV")
Set General_mA = .Range("General_mA")
Set General_Timer = .Range("General_Timer")
(...etc. approx 90 other Set statements).
End With

I can recover the named ranges from the Lookup worksheet but I don't know
how (or if) it's possible to apply them to a variable in the Set statement.

What I'm hoping for is something along the lines of the following code but I
need both instances of X to be substituted with General_kV, General_mA,
General_Timer, etc.

Sub SetRanges()
Set nms = ThisWorkbook.Names
For r = 1 To nms.Count
X = nms(r).Name
If Left(nms(r).RefersTo, 8) = "=Lookup!" Then
Set X = Worksheets("Lookup").Range(X)
End If
Next
Set nms = Nothing
End Sub


Any ideas?

--
Ian
--


 
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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Read ".dll" files, the Macro "work flow" and the actual values of the variables when Macro is running [email protected] Excel Programming 5 May 16th 07 08:18 PM
embedding "ISERROR" function into an "IF" statement [email protected] Excel Worksheet Functions 8 January 4th 07 12:01 AM
Call a sub statement in "Personal Macro Workbook" from "ThisWorkbo QC Coug Excel Programming 1 August 26th 05 07:09 PM
vba: How do I write a "For Each Statement" nested in a "With Statement"? Mcasteel[_29_] Excel Programming 0 November 8th 04 09:08 PM


All times are GMT +1. The time now is 03:01 PM.

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"