Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Ending Procedure When Condition is Met Anywhere in Procedure

I have a file I use to reconcile 2 sets of numbers. What I would like is to
end the procedure the moment the difference between the numbers is 0.

The way my file works is that when the file is opened, I am prompted to
enter information into cells through a series of Input Boxes. At certain
points, I make the macro stop if the cell containing the difference equals 0.
It works great, but I would like to have the macro stop the moment the
difference = 0.

Here is my macro:

Private Sub Test()
'Enters information
Application.StatusBar = "Enter information."
Entry = MsgBox("Activate Wizard?", vbQuestion + vbYesNo, "Data Entry")
If Entry = vbYes Then
Application.Run (Macro)
Else:
Call Messages.Messages
End
End If
'Prompts to enter Target and Data1
Range("Target").Value = InputBox("Enter target figu", "Wizard: Target")
Range("1").Value = InputBox("Enter Figure1 amount:", "Wizard: Figure1")
Range("2").Value = InputBox("Enter Figure2 amount:", "Wizard: Figure2")
Range("3").Value = InputBox("Enter Figure3 amount:", "Wizard: Figure3")
If Range("Difference").Value = 0 Then
Sheets(2).Activate
End
End If
'Prompts to enter Data2 if Difference < 0
Data2 = MsgBox("Is there Data2?", vbQuestion + vbYesNo, "Data2")
If Data2 = vbYes Then
Range("4").Value = InputBox("Enter Figure4 amount:", "Wizard: Figure4")
Range("5").Value = InputBox("Enter Figure5 amount:", "Wizard: Figure5")
Range("6").Value = InputBox("Enter Figure6 amount:", "Wizard: Figure6")
End If
If Range("Difference").Value = 0 Then
Sheets(2).Activate
End
End If
'Prompts to enter Data3 if Difference < 0
Data3 = MsgBox("Enter Data3?", vbQuestion + vbYesNo, "Data3")
If Data3 = vbYes Then
Range("7").Value = InputBox("Enter Figure7:", "Wizard: Figure7")
Range("8").Value = InputBox("Enter Figure8 amount:", "Wizard: Figure8")
Range("9").Value = InputBox("Enter Figure9:", _
"Wizard: Figure9", Abs(Range("Difference").Value))
End If
'Displays report
Sheets(2).Activate
Call Messages.Messages
End Sub

You'll notice the recurring code:

If Range("Difference").Value = 0 Then
Sheets(2).Activate
End
End If

I want to enter that once in my module and execute that IF statement the
moment it is true. Thanks.

(The numbered range names are fake; I know they are illegal in Excel)
--
I am running on Excel 2003, unless otherwise stated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Ending Procedure When Condition is Met Anywhere in Procedure

Just a note:
I would like this to start searching after I enter my target figure.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Ending Procedure When Condition is Met Anywhere in Procedure

I found a workaround with a separate procedure I call after each point in
data entry.
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
Stop Procedure when an Error occurs in another procedure RyanH Excel Programming 4 October 15th 08 08:11 PM
Is there a simple procedure to hide rows if a condition is met fishingengineer Excel Discussion (Misc queries) 1 April 13th 07 08:26 PM
How to jump from a Form procedure to a Workbook or Module procedure? T. Erkson Excel Programming 4 January 25th 07 07:15 PM
prevent event procedure under condition short_n_curly Excel Programming 3 June 27th 05 08:38 PM


All times are GMT +1. The time now is 04:01 PM.

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"