Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default How do I get a Yes/No message box to loop

Try this

Sub Test()
Dim PartNum As String
Do
PartNum = InputBox("Enter in Part Number:", "Part Number")
If PartNum = "" Then End
Loop Until MsgBox("The Part Number is: " & PartNum, vbYesNo) = vbYes
Worksheets("Sheet1").Range("H10").Value = PartNum
End Sub

Mike

"John" wrote:

Hello! I need help with a Yes/No message box loop. The code I have written
works but not the way I would like for it to work. I want my loop to ask me
each time Is this the part number yes/no until I click yes. It works the
first time through properly.
The second time when I put in my number and click ok it loops out into the
program. I want it to ask me the yes/no question. My code is below:

Sub Test()
Dim PartNum As String
PartNum = InputBox("Enter in Part Number:", "Part Number")

Do
If PartNum = "" Then End
If MsgBox("The Part Number is: " & PartNum, vbYesNo) = vbNo Then
PartNum = InputBox("Enter in Part Number:", "Part Number")
End If
Loop While vbYesNo = vbYes

Worksheets("Sheet1").Range("H10").Value = PartNum
End Sub

Thanks for the help in advance...

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
Do Loop Vs For Each jlclyde Excel Discussion (Misc queries) 3 September 29th 08 08:48 PM
Loop Wanna Learn Excel Discussion (Misc queries) 5 January 31st 07 05:21 PM
Do Loop Noemi Excel Discussion (Misc queries) 0 December 8th 05 10:43 PM
Help with Do...Loop Noemi Excel Discussion (Misc queries) 1 December 7th 05 12:59 AM
changing the message in an error message The Villages DA Excel Worksheet Functions 2 February 18th 05 05:30 PM


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