A little help needed....

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
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Does this work?
Code:
Private Sub CommandButton1_Click()

    If Range("ij11") < 3 Then
        MsgBox ("You in provided.")
        Exit Sub
    End If
    
    Range("II8:II10").Copy
    
    Range("IO6").End(xlDown).Offset(1, 0).PasteSpecial Paste:=xlValues
    
    Range("it8") = Range("it7") + Range("iu7")
    
    Range("ii8:ii10") = ""
    
    Unload Me
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,519
Members
448,968
Latest member
Ajax40

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top