Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Use of Public for data declaration in Excel 2000

I want to use the same data in sub routines in different sheets of a workbook.
I wrote the following test routines, the first pair "in Sheet 1" and the
last "in Sheet 2"
The variable InUseCol was accessible to both routines in Sheet 1, but the
routine in Sheet 2 could not access it - returns a null value

Sheet 1

Public InUseCol As Integer
Sub GenTest()

InUseCol = 5
MsgBox InUseCol, vbOKOnly, "Selected Column"
End Sub
Sub TestingSh1()
MsgBox InUseCol, vbOKOnly, "Box 2"
End Sub

Sheet 2

Sub TestingSh2()
MsgBox InUseCol, vbOKOnly, "Box 3"
End Sub

Assistance much appreciated
Gandalph
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 533
Default Use of Public for data declaration in Excel 2000

Typically public variable should be put in standard modules (Insert, Module)
rather than sheet modules. They can be seen from anywhere in the project.

Alternatively you can pint to them by using the codename of the sheet
module:

Sub TestingSh1()
MsgBox Sheet1.InUseCol, vbOKOnly, "Box 2"
End Sub


--
Jim
"Gandalph" wrote in message
...
|I want to use the same data in sub routines in different sheets of a
workbook.
| I wrote the following test routines, the first pair "in Sheet 1" and the
| last "in Sheet 2"
| The variable InUseCol was accessible to both routines in Sheet 1, but the
| routine in Sheet 2 could not access it - returns a null value
|
| Sheet 1
|
| Public InUseCol As Integer
| Sub GenTest()
|
| InUseCol = 5
| MsgBox InUseCol, vbOKOnly, "Selected Column"
| End Sub
| Sub TestingSh1()
| MsgBox InUseCol, vbOKOnly, "Box 2"
| End Sub
|
| Sheet 2
|
| Sub TestingSh2()
| MsgBox InUseCol, vbOKOnly, "Box 3"
| End Sub
|
| Assistance much appreciated
| Gandalph


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
Get data from Outlook Public Folders in Excel Wim VR[_2_] Excel Programming 0 August 17th 07 03:06 PM
Declaration of public variable - Question Les Stout[_2_] Excel Programming 2 October 5th 05 02:53 PM
2nd try --Macro to transfer data in an Excel sheet (2000) in Access 2000 ( code to replace what wizard do) André Lavoie Excel Programming 0 September 27th 05 01:50 PM
Public declaration Greg[_16_] Excel Programming 2 January 21st 05 10:53 PM
public declaration kevin Excel Programming 1 December 6th 03 07:00 PM


All times are GMT +1. The time now is 06:33 AM.

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"