VBA code for poping out an error message box

J

jaymai108

Anyone know the VBA code for poping out an error message box?
I am creating a worksheet where the user can enter values to certain
cells before clicking the "run" command button, and when the button is
clicked, i want it to check wheather the cells that require input are
filled, if not, then a message box will pop out saying "error"
thanks
jay
 
D

Dave Peterson

Option Explicit
Sub testme()
dim myRng as range

with activesheet
set myrng = .range("a1,b3,c9,d12,f99")
end with

if myrng.cells.count <> application.counta(myrng) then
msgbox "Please complete all the cells!
exit sub
end if

'rest of code

End Sub
 

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