View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
gocush[_29_] gocush[_29_] is offline
external usenet poster
 
Posts: 252
Default Initialize a Private variable

Tom,

If the variable in declared as Private, I was under the impression that it's
value diappears at the end of the procedure in which you set the value. If
this is the case, the OP would have to reset the value in any other sub where
he wanted to use the variable.

I have always thought that if the OP wanted to set the value as you did in
the Workbook_Open event for use somewhere else, then the variable would have
to be declared Public

Am I confused?

"Tom Ogilvy" wrote:

You can do it in the workbook_Open event

Private Sub Workbook_Open()
OutLookDate = DateSerial(Year(Date),Month(Date)+6,1)
End Sub

Place this in the ThisWorkbook Module

See Chip Pearson's page on events
http://www.cpearson.com/excel/events.htm


Or just set it in your first macro that is to run.

--
Regards,
Tom Ogilvy


"jerry chapman" wrote in message
m...
I have a private variable:

Private outlookDate As Date

How can I set the value of this variable before I run any macros?