Can anybody suggest where I should go with this please? I would like this if statement to loop until the user clicks "Yes":
Does this make sense? I'd like the user to be able to hit no and have the code loop until they are sure the inputs are correct. Currently, the routine is linked to a manual button the user has to press to kick off the code but, of course, the routine just ends when they haven't got it right so they then have to press the button again if they answer "No".
Many thanks all.
Rich
Code:
Sub Period_Year_Input()
Dim Answer1 As String
Dim MyNote1 As String
FinancialYear1 = InputBox("What financial year is this report for? (YYYY)", "Financial Year Input")
Period1 = InputBox("What period is this report for? (1-12)", "Period Input")
MyNote1 = "Are you sure that this report is for P" & Period1 & ", " & FinancialYear1 & "?"
Answer1 = MsgBox(MyNote1, vbQuestion + vbYesNo, "Richosoft Excel")
If Answer1 = vbNo Then
[green]'Instead of "Exit Sub" here, I'd like the routine to loop back to the start so the user can correct any mistakes
[/green]
Exit Sub
Else
End If
[green]
'Rest of code here
[/green]
End Sub
Does this make sense? I'd like the user to be able to hit no and have the code loop until they are sure the inputs are correct. Currently, the routine is linked to a manual button the user has to press to kick off the code but, of course, the routine just ends when they haven't got it right so they then have to press the button again if they answer "No".
Many thanks all.
Rich