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

Hi Slarbie

Instead of putting 'Public const MyRange as Range = Range("MyRange")', put
the following in the top of general module:

Public My Range As Range 'Don't put the word 'Const'

Than in the Open workbook event, set the range object as follows:

Private Sub Workbook_Open()
Set MyRange = ThisWorkbook.Worksheets("Sheet1").Range("MyRange")
End Sub

Next time you execute Workbook_Open() This will allow you to use 'MyRange'
anywhere in the project

Hope this helps
--
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!