#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default if - loop?


Hi,
If the user input the wrong info, a msg will pop up. How can i prevent the
macro from running through the rest, but instead loop back until the user
inputs the correct info?
Thanks,
Stefan

....
....
If [ccard2].Formula Like "#" Then ' 1
MsgBox "Please enter 5 digits." & Chr(10) _
& "I.e. '04' for month, '/' for the divider and '05' for the year." &
Chr(10) _
& "This would look like 04/05." _
& Chr(10) & Chr(10) & "Thank you.", vbInformation, "Incorrect Entry
Notice"
Range("ccard2").Select
End If
MsgBox "Thank you."
....
....


--
Message posted via http://www.officekb.com
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default if - loop?

Stefan,

Dim Flag
Flag = 0
Do Until Flag = 1
Flag = 1
If [ccard2].Formula Like "#" Then ' 1
MsgBox "Please enter 5 digits." & Chr(10) _
& "I.e. '04' for month, '/' for the divider and '05' for the
year." &
Chr(10) _
& "This would look like 04/05." _
& Chr(10) & Chr(10) & "Thank you.", vbInformation, "Incorrect
Entry
Notice"
Range("ccard2").Select
Flag = 0
End If
Loop
MsgBox "Thank you."



"stefan via OfficeKB.com" wrote in message
...

Hi,
If the user input the wrong info, a msg will pop up. How can i prevent the
macro from running through the rest, but instead loop back until the user
inputs the correct info?
Thanks,
Stefan

...
...
If [ccard2].Formula Like "#" Then ' 1
MsgBox "Please enter 5 digits." & Chr(10) _
& "I.e. '04' for month, '/' for the divider and '05' for the year."
&
Chr(10) _
& "This would look like 04/05." _
& Chr(10) & Chr(10) & "Thank you.", vbInformation, "Incorrect Entry
Notice"
Range("ccard2").Select
End If
MsgBox "Thank you."
...
...


--
Message posted via http://www.officekb.com



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
Find loop doesn't loop JSnow Excel Discussion (Misc queries) 2 June 24th 09 08:28 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
How do I create a For loop within a For loop? Linking to specific cells in pivot table Excel Programming 2 January 24th 05 08:05 AM
For/Loop skipping one value in loop only Matt Jensen Excel Programming 6 January 8th 05 12:03 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 09:16 PM.

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"