Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default 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
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 variable Jack New Users to Excel 4 March 18th 06 09:35 PM
Maintaining cell 'variable' values even after the the macro has en tomwashere2 Excel Programming 1 August 18th 05 11:44 PM
Maintaining VBA variable values Adam1 Chicago Excel Discussion (Misc queries) 3 March 14th 05 11:08 PM
Public Variable Jason Excel Programming 4 April 12th 04 07:06 PM
public variable marwan hefnawy Excel Programming 1 September 5th 03 08:54 AM


All times are GMT +1. The time now is 08:40 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"