Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Do Loop Vs For Each | Excel Discussion (Misc queries) | |||
Loop | Excel Discussion (Misc queries) | |||
Do Loop | Excel Discussion (Misc queries) | |||
Help with Do...Loop | Excel Discussion (Misc queries) | |||
changing the message in an error message | Excel Worksheet Functions |