Public variables

T

Tomski

Hi,

My public variables can't be referenced by sub routines in my modules.
The two msgboxes in the code below display them correctly.


Public newDataSheet As Worksheet
Public nikkeiTime As Date

Private Sub Workbook_Open()

Set newDataSheet = Workbooks("Historic Data").Worksheets("NewData")
nikkeiTime = "00:00:05"

MsgBox nikkeiTime
MsgBox newDataSheet.name

Application.OnTime Now + TimeValue("00:00:01"), "runSchedule"

End Sub


However the msgboxes in runSchdule are blank, code shown below

Sub runSchedule()

MsgBox nikkeiTime
MsgBox newDataSheet.name

End Sub

Can anybody help me with this one please?

Thanks

T:)
 
G

Guest

Put the public variables in a general module, not the thisworkbook module.
You can still initialize them in the Workbook_Open event. Your runSchedule
routine should also be in a general module.
 
S

Snake Plissken

Set newDataSheet = Workbooks("Historic Data").Worksheets("NewData")


does it really work ??

dont think so

why dont you use "option explicit" directive ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top