LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Keeping Values in Variables

Hi,
I am trying to write code for the user to ensure that they have checked for
certain criteria before they protect the sheet. My code is as below. However,
if a criteria is not met then the user exits the sub routine, corrects the
criteria and presses the submit button again. However, I do not wish the
message boxes that have already been dealt with to show again. Hence If test1
is not zero then do not invoke the message box and carry on . The problem is
when the sub is exited the variables loose their value and you have to start
the routine from scratch. How can I get over this?

Public Sub CommandButton1_Click()
Dim Reply As Integer
Dim Test1 As Integer
Dim Test2 As Integer
Dim Test3 As Integer

If Test1 = 0 Then
Reply = MsgBox("Test 1", vbYesNo, "Title")
If Reply = vbYes Then
Test1 = 1
Else
Test1 = 1
Exit Sub
End If
End If

If Test2 = 0 Then
Reply = MsgBox("Test 2", vbYesNo, "Title")
If Reply = vbYes Then
Test2 = 1
Else
Test2 = 1
Exit Sub
End If
End If

If Test3 = 0 Then
Reply = MsgBox("Test 3", vbYesNo, "Title")
If Reply = vbYes Then
Test3 = 1
Else
Test3 = 1
Exit Sub
End If
End If

End sub
 
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
keeping values AFL-math Excel Discussion (Misc queries) 2 April 1st 10 10:46 PM
keeping a shape constant regardless of changes in variables Osvy Excel Discussion (Misc queries) 0 March 28th 06 04:49 AM
Keeping variables in a formula Brian Mann Excel Discussion (Misc queries) 1 September 22nd 05 09:13 PM
Keeping a Variables value alive. Chris W[_3_] Excel Programming 1 March 19th 05 11:54 AM
Keeping track of Global variables Stuart[_5_] Excel Programming 3 July 15th 04 02:14 PM


All times are GMT +1. The time now is 08:14 AM.

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

About Us

"It's about Microsoft Excel"