![]() |
Problem getting the value of a Named Range in code
I'm not very experienced with Excel VBA yet, so I often use the
immediate window to try out various syntax before coding it up. I found something that works in the immediate window when nothing is running: ? Range("OnSiteRate").value does NOT work when the code is run or in the immediate window with the code paused due to the error. I found a workaround: ? ThisWorkbook.Names("OnSiteRate").RefersToRange but I'm curious as to why this doesn't work in both circumstances. Thanks tbone |
Problem getting the value of a Named Range in code
Both methods work for me.
If you tried to used Range("OnSiteRate").value in a sheet module and the named range "OnSiteRate" was on another sheet, then you have to qualify it with the sheet name where it exists because an unqualifed "Range" reference in a sheet module is the same as saying me.Range In a general module, you don't have this problem. -- Regards, Tom Ogilvy "tbone" wrote in message ... I'm not very experienced with Excel VBA yet, so I often use the immediate window to try out various syntax before coding it up. I found something that works in the immediate window when nothing is running: ? Range("OnSiteRate").value does NOT work when the code is run or in the immediate window with the code paused due to the error. I found a workaround: ? ThisWorkbook.Names("OnSiteRate").RefersToRange but I'm curious as to why this doesn't work in both circumstances. Thanks tbone |
All times are GMT +1. The time now is 04:19 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com