View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Greg Wilson Greg Wilson is offline
external usenet poster
 
Posts: 747
Default "Using A Variable On Several Sheets"

Declare the variable as Public at the top of a standard module instead of
inside a procedure. Then when your code modifies it, the other code can also
refer to its value. For example:

Public myRow As Long

Sub Procedure1()
myRow = 100
End Sub

Sub Procedure2()
MsgBox myRow
End Sub

The variable's value will persist as long as the workbook is open or until
an unhadled error occurs.

Greg


"Don" wrote:

Hi There,

Hope I can explain this correctly...I have a variable that was assigned a
numerical value using code identifying the last row used on "Sheet1". The
value of the variable changes as data changes on "Sheet1". I need to be able
to pick up this numerical value in code for several other sheets in the same
WB. Is there a method to store this variable so as to be able to use it from
all sheets in the WB?

Probably something very simple but I'm still learning....:)

TIA....Don