MrExcel Publishing
Your One Stop for Excel Tips & Solutions

dimension statements and public variables


Posted by j.r. on December 23, 2000 8:25 AM

First let me say how much I appreciate all the help you guys have been to me. I wish you all a very Merry Christmas.

I have a question about a simple subroutine below that's driving me nuts. When I go to the subroutine called "test", the "j" variable and "sales" variable do not pass through. If I REM out the dimension statements, they pass through. How can I dimnsion my variables and use the value of the variables in subroutines in other parts of my program?

Public j
Public sales
--------------------------------------------------
Sub begin()

Dim j As Integer
Dim sales As String
sales = "$10"

For j = 1 To 2
Call test
Next j

End Sub

Sub test()
MsgBox "j = " & j
MsgBox "sales = " & sales
End Sub


Posted by Dave on December 23, 2000 12:33 PM

Hi jr

Merry Xmas to you too!

Try this:

Public j As Integer
Public sales As String

Sub begin()

sales = "$10"

For j = 1 To 2
Call test
Next j

End Sub

Sub test()
MsgBox "j = " & j
MsgBox "sales = " & sales
End Sub


OzGrid Business Applications