View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Tim Zych Tim Zych is offline
external usenet poster
 
Posts: 389
Default Public Range Constant - how do I?

If you use my 2nd solution, you can test for the validity of the range
object, and if Nothing, run RefreshGlobalRanges. Or, just run it at the
beginning of each procedure/function.

Sub RunMacro()
If MyRange Is Nothing Then
' Something bad happened, so refresh everything
Call RefreshGlobalRanges
End if

End Sub

or

Sub RunMacro()
' Refresh everything as a defensive maneuver to:
' - Fix broken references
' - Resize modified ranges
Call RefreshGlobalRanges

End Sub

--
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility
Free and Pro versions


"slarbie" wrote in message
...
Thanks again, I was just setting about to figure out why it had stopped
working. Hmmm. I'll have to figure out how I want to deal with that...
Is
it preventable if I have sufficiently robust error handling in the
procedures, so break mode doesn't happen?

"Howard31" wrote:

Keep in mind that if in any time after setting the range object, the VB
goes
into Break mode, the range object will become disassociated from
"MyRange",
that means it will become an empty range variable = Nothing and you'll
have
to reset it to "MyRange"
--
A. Ch. Eirinberg


"slarbie" wrote:

In all the modules/procedures of my project, I'd like to be able to
refer to
a specific named range as a constant. I imagined this:

Public const MyRange as Range = Range("MyRange")

at the top of a module, but it doesn't work. Can someone help with the
right way to do what I'm trying to get at here? Thanks!