Kevin, I think you mean
If Cells(1,1) = "" or Cells(1,1) = "0" Then
Cells(1,1).Select
MsgBox "Please fill in a non-zero value for A1"
Exit Sub
End If
Main Topics
Browse All TopicsIs there a way to check the value of a cell as being non-zero, before running a macro? If cell value is zero, prompt user to fill it in and try to run the macro again (or have it continue on automatically)?
Thanks,
Brent
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Fantastic responses guys. Thanks! Kevin, your solution inspired this solution. The "exit sub" command was the missing piece for me. Here's my finished solution with a twist... I'm open to suggestions if you see a better way to do this...
If ActiveSheet.Range("T7").Va
'this is only tested if value of T7 is "job pull". Other values skip this whole routine.
If Worksheets("Master Inventory").Range("C1").Va
'tests the "job number" cell which is on a different sheet called "master inventory".
Worksheets("Master Inventory").Range("C1") = InputBox(Prompt:="Enter a Job Number",_
Title:="Missing Job Number")
'If job number cell test is zero, an input box opens that will take their input job number
'and fill in the job number for the user in C1.
If Worksheets("Master Inventory").Range("C1").Va
Exit Sub
'This if statement tests for the user hitting cancel which returns a null...if null, then exits macro.
End If
End If
End If
If ActiveSheet.Range("O7").Va
If Worksheets("Master Inventory").Range("C1").Va
'double-checks to make sure user didn't put in zero as a job number and hit OK in the last input box.
'I couldn't find a way to nest in with former if statements. But it works fine this way...
Exit Sub
'exits macro if job number is still zero
End If
End If
'At this point there will be a non-zero job number if user is creating a "job pull", so the macro will
'continue normally as though the job number had always been there.
'rest of macro code continues here...
(same code as above, without all my distracting comments):
Sub TallySubtraction()
If ActiveSheet.Range("O7").Va
If Worksheets("Master Inventory").Range("C1").Va
Worksheets("Master Inventory").Range("C1") = InputBox(Prompt:="Enter a Job Number",_
Title:="Missing Job Number")
If Worksheets("Master Inventory").Range("C1").Va
Exit Sub
End If
End If
End If
If ActiveSheet.Range("O7").Va
If Worksheets("Master Inventory").Range("C1").Va
Exit Sub
End If
End If
Business Accounts
Answer for Membership
by: zorvekPosted on 2007-11-27 at 11:53:57ID: 20360759
If Len([A1]) = 0 Then
MsgBox "Enter value in A1."
Exit Sub
End If
Kevin