Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Public Variable not maintaining value.
I have the following code segment. WbkCount is a public variable which is
declared in ThisWorkbook. I want that variable to count how many times the the user creates a certain report. This code is initialized when a command button is selected. So far, every time I run the code, Msgbox wbkcount is returning a "1"... no matter how many times I run it. Oddly, I can't find any place where the variable could be resetting. result = MsgBox("Please confirm that you wish to create the " & Counter & " selected report(s).", vbOKCancel, "Continue?") If result = vbOK Then WbkCount = WbkCount + 1 ReDim Preserve Wbks(0 To WbkCount) Application.SheetsInNewWorkbook = Counter MsgBox WbkCount Set Wbks(WbkCount) = Workbooks.Add For i = 1 To Counter Worksheets(i).Name = Reported(i) Next i Else Exit Sub End If |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Public Variable not maintaining value.
move it to a module such as Module1
"Mark" wrote: I have the following code segment. WbkCount is a public variable which is declared in ThisWorkbook. I want that variable to count how many times the the user creates a certain report. This code is initialized when a command button is selected. So far, every time I run the code, Msgbox wbkcount is returning a "1"... no matter how many times I run it. Oddly, I can't find any place where the variable could be resetting. result = MsgBox("Please confirm that you wish to create the " & Counter & " selected report(s).", vbOKCancel, "Continue?") If result = vbOK Then WbkCount = WbkCount + 1 ReDim Preserve Wbks(0 To WbkCount) Application.SheetsInNewWorkbook = Counter MsgBox WbkCount Set Wbks(WbkCount) = Workbooks.Add For i = 1 To Counter Worksheets(i).Name = Reported(i) Next i Else Exit Sub End If |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Public variable | New Users to Excel | |||
Maintaining cell 'variable' values even after the the macro has en | Excel Programming | |||
Maintaining VBA variable values | Excel Discussion (Misc queries) | |||
Public Variable | Excel Programming | |||
public variable | Excel Programming |