Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Public variables


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:)


--
Tomski
------------------------------------------------------------------------
Tomski's Profile: http://www.excelforum.com/member.php...o&userid=26824
View this thread: http://www.excelforum.com/showthread...hreadid=570344

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Public variables

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.

--
Regards,
Tom Ogilvy


"Tomski" wrote:


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:)


--
Tomski
------------------------------------------------------------------------
Tomski's Profile: http://www.excelforum.com/member.php...o&userid=26824
View this thread: http://www.excelforum.com/showthread...hreadid=570344


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Public variables

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


does it really work ??

dont think so

why dont you use "option explicit" directive ?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Public variables


Thanks mate, just the job.

T


--
Tomski
------------------------------------------------------------------------
Tomski's Profile: http://www.excelforum.com/member.php...o&userid=26824
View this thread: http://www.excelforum.com/showthread...hreadid=570344

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
public variables johnny Excel Discussion (Misc queries) 7 February 27th 08 03:44 PM
Public variables johnny Excel Discussion (Misc queries) 2 February 24th 08 05:05 AM
Public Variables Jerry McNabb Excel Discussion (Misc queries) 0 February 24th 08 01:26 AM
Public Variables [email protected] Excel Programming 1 September 1st 05 04:14 PM
Public Variables Les Gordon Excel Programming 2 November 11th 04 12:29 PM


All times are GMT +1. The time now is 12:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"