ExcelNovice
Well-known Member
- Joined
- May 12, 2002
- Messages
- 583
Hi all,
There is a command button on my spreadsheet. When selected, it opens a Userform that users are asked to complete and then close on the OK button to run the macros below:
The first line of the macro will cause a message box to appear if the userform is not completely filled out. This works great now, except that when the user closes the message box the remaining portion of the code is activated and the userform closes. How do I write this so that when the user closes the message box, the userform remains open and the user is able to complete the form?
The code I'm using is below:
Private Sub CommandButton1_Click()
If Range("ij11") < "3" Then MsgBox ("You in provided.")
Range("II8:II10").Select
Selection.Copy
Range("IO6").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("II7").Select
Application.CutCopyMode = False
ActiveWindow.Panes(1).Activate
Range("D6").Select
Range("it8") = Range("it7") + Range("iu7")
Range("ii8") = ""
Range("ii9") = ""
Range("ii10") = ""
Unload Me
End Sub
There is a command button on my spreadsheet. When selected, it opens a Userform that users are asked to complete and then close on the OK button to run the macros below:
The first line of the macro will cause a message box to appear if the userform is not completely filled out. This works great now, except that when the user closes the message box the remaining portion of the code is activated and the userform closes. How do I write this so that when the user closes the message box, the userform remains open and the user is able to complete the form?
The code I'm using is below:
Private Sub CommandButton1_Click()
If Range("ij11") < "3" Then MsgBox ("You in provided.")
Range("II8:II10").Select
Selection.Copy
Range("IO6").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("II7").Select
Application.CutCopyMode = False
ActiveWindow.Panes(1).Activate
Range("D6").Select
Range("it8") = Range("it7") + Range("iu7")
Range("ii8") = ""
Range("ii9") = ""
Range("ii10") = ""
Unload Me
End Sub