Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
refering to a named range on a different worksheet
I have code that refers to a named range:
Dim name1, name2, varRange, c, rowCount name2 = ActiveWorkbook.Names("Range") rowCount = ActiveSheet.Range(name2).Value 'Original "Range" is a named range on Sheet2 If sheet 2 is active when I run the code the value of "Range" loads correctly. However, I need this to work when I have sheet1 active. Trying this I get "Application-defined or object-defined error" probably because of the "activesheet" object... I tried: rowCount = ActiveWorkbook.Range(name2).Value and get "Object doesn't support this property or method (Error 438)" Clearly Im missing something here, any help will be appreciated. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
refering to a named range on a different worksheet
You need to tell what sheet the named range is on, try this in your
code: rowCount = Worksheets("Sheet2").Range(name2).Value Sandy wrote: I have code that refers to a named range: Dim name1, name2, varRange, c, rowCount name2 = ActiveWorkbook.Names("Range") rowCount = ActiveSheet.Range(name2).Value 'Original "Range" is a named range on Sheet2 If sheet 2 is active when I run the code the value of "Range" loads correctly. However, I need this to work when I have sheet1 active. Trying this I get "Application-defined or object-defined error" probably because of the "activesheet" object... I tried: rowCount = ActiveWorkbook.Range(name2).Value and get "Object doesn't support this property or method (Error 438)" Clearly Im missing something here, any help will be appreciated. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
refering to a named range on a different worksheet
thanks Sandy, that works!
Sandy wrote: You need to tell what sheet the named range is on, try this in your code: rowCount = Worksheets("Sheet2").Range(name2).Value Sandy wrote: I have code that refers to a named range: Dim name1, name2, varRange, c, rowCount name2 = ActiveWorkbook.Names("Range") rowCount = ActiveSheet.Range(name2).Value 'Original "Range" is a named range on Sheet2 If sheet 2 is active when I run the code the value of "Range" loads correctly. However, I need this to work when I have sheet1 active. Trying this I get "Application-defined or object-defined error" probably because of the "activesheet" object... I tried: rowCount = ActiveWorkbook.Range(name2).Value and get "Object doesn't support this property or method (Error 438)" Clearly Im missing something here, any help will be appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can you name a worksheet by refering to a cell reference or range | Excel Discussion (Misc queries) | |||
Do not specify worksheet in a named range | Excel Discussion (Misc queries) | |||
Refering to a named range in a chart: 2007 | Excel Worksheet Functions | |||
Getting a named range to appear in another worksheet | Excel Discussion (Misc queries) | |||
help in refering to a range named in a cell | Excel Programming |