Question : Creating a Constant in VBA Which References a Range

I am trying to simplify my code by defining some constants.  I am having some problems defining a few of them though.  I am trying to set up a constant which references a range of cells I define on the sheet.

Here's what I have tried so far:

/* Defined Name on Sheet */
lineAOffset ='Daily Report'!$B$16

Public Const LINE_A_OFFSET As Range = Range("lineAOffset")

or

Public Const LINE_A_OFFSET As Range = Range(lineAOffset)

Neither of these ways worked, and I am stumped as to why.  Any help would be greatly appreciated.  Thanks.

--Charly

Answer : Creating a Constant in VBA Which References a Range

Patrick is correct. Try these alternatives:

Public LINE_A_OFFSET As Range
Set LINE_A_OFFSET = Range("lineAOffset")

Or...

Public Const LINE_A_OFFSET = "lineAOffset"

Dim LINE_A_OFFSET_RANGE As Range
Set LINE_A_OFFSET_RANGE = Range(LINE_A_OFFSET)

Kevin
Random Solutions  
 
programming4us programming4us