Run Macro Only If 4 Cells Are Filled In By User In VBA

C

Celtic_Avenger

Thanks Norman.

I have made a few user specific adjustments:

Private Sub CommandButton1_Click()
Dim rng As Range

Set rng = Range("E6, E8,E10,E12")

If Application.CountA(rng) < 4 Then
MsgBox "Please Complete At Least The Following" & Chr(13) & "Custome
Name." & Chr(13) & "Customer Number." & Chr(13) & "Credit Limit."
Chr(13) & "Current Balance.", vbInformation, "IMPORTANT!"
Exit Sub

Else
Sheets("Lock2").Select
Application.StatusBar = "Please Enter The Details Requested The
Press The Next Button"
ActiveWindow.DisplayVerticalScrollBar = False

End If

End Sub

And this now works an absolute treat.

Thanks for all your help with this question and all the others I hav
posted that you have been very kind to help me on. Big Help.

Thanks again.

Celtic_Avenger
:) :) :) :) :
 
D

Dave Peterson

I'd change this:

If Application.CountA(rng) < 4 Then
to
If Application.CountA(rng) < rng.cells.count then

Then if you increase/decrease the cells in rng, you don't have to worry about
finding all the 4's and adjusting them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top