ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel2000: Reading Named Range value from VBA (https://www.excelbanter.com/excel-programming/303636-excel2000-reading-named-range-value-vba.html)

Arvi Laanemets

Excel2000: Reading Named Range value from VBA
 
Hi

Is it possible at all, and when yes, then how? To be more specific, I want
to write an workbook Open event, where I need the current weeknumber string
in format "yyyy.ww". There is a named range/function CurrWeek defined in
workbook, which returns exactly the value I need, but how do I get it? I
checked with Watch window, and the expression:
ActiveWorkbook.Names("CurrWeek")
doesn't return "2004.28" today - instead it returns
"=INDEX(Weeks_Week,MATCH(VLOOKUP(TODAY(),Weeks_Sta rt,1,1),Weeks_Start,0))"
i.e. the 'Refers To' part of name definition (Weeks_Week and Weeks_Start are
named ranges which do return ranges from a table). And the same with:
ActiveWorkbook.Names("CurrWeek").Value


--
Arvi Laanemets
(When sending e-mail, use address arvil<Attarkon.ee)



Charles Williams

Excel2000: Reading Named Range value from VBA
 
Hi Arvi,

try either
[CurrWeek]

or
Application.evaluate("CurrWeek")


regards
Charles
______________________
Decision Models
The Excel Calculation Site.
www.DecisionModels.com
"Arvi Laanemets" wrote in message
...
Hi

Is it possible at all, and when yes, then how? To be more specific, I want
to write an workbook Open event, where I need the current weeknumber

string
in format "yyyy.ww". There is a named range/function CurrWeek defined in
workbook, which returns exactly the value I need, but how do I get it? I
checked with Watch window, and the expression:
ActiveWorkbook.Names("CurrWeek")
doesn't return "2004.28" today - instead it returns
"=INDEX(Weeks_Week,MATCH(VLOOKUP(TODAY(),Weeks_Sta rt,1,1),Weeks_Start,0))"
i.e. the 'Refers To' part of name definition (Weeks_Week and Weeks_Start

are
named ranges which do return ranges from a table). And the same with:
ActiveWorkbook.Names("CurrWeek").Value


--
Arvi Laanemets
(When sending e-mail, use address arvil<Attarkon.ee)





Arvi Laanemets

Excel2000: Reading Named Range value from VBA
 
Thanks! It works!

Arvi Laanemets




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com