ERROR Checking Before Running Program

P

Paul Black

Hi everyone,

I need to be able to check whether the data entered is the actaul data
that needs to be processed.
The program I have works GREAT so it is just a case of fine tuning the
criteria to use.
I would like to do the following please.
So far I have ...

Code:-
Set rngA = Worksheets("A").Range("B2").UsedRange.Rows
Set rngB = Worksheets("A").Range("B4").UsedRange.Rows

.... and would like to ADD the following, I know Numbers 1 AND 3 will
use vbYesNo and Numbers 2 AND 4 will use vbYesNoCacel :-

Number 1
--------------
If rngA is NOTHING Then
MsgBox = "Text goes here"
If YES goto rngA and Exit Sub
If NO Exit Sub

Number 2
--------------
If rngA is NOT NOTHING Then
MsgBox "Text goes here"
If YES continue running the program
If NO goto rngA and Exit Sub
If CANCEL Exit Sub

Number 3
--------------
If rngB is NOTHING Then
MsgBox = "Text goes here"
If YES goto rngB and Exit Sub
If NO Exit Sub

Number 4
--------------
If rngB is NOT NOTHING Then
MsgBox "Text goes here"
If YES continue running the program
If NO goto rngB and Exit Sub
If CANCEL Exit Sub

Number 5
--------------
If Number 2 AND Number 4 = YES Then
On Error Resume Next
Worksheets("B").Delete
On Error GoTo 0
Worksheets.Add(After:=Worksheets("A")).Name = "B"
Cells.Font.Name = "Tahoma"

The actual program then starts here.

P = Application.Max(rngB)
etc
etc
etc

Thanks in Advance.
All the Best.
Paul
 
G

Guest

Paul

I think you want something like the following:

If rnA.cells.count=0 then
Ans=Msgbox("Text goes here",vbYesNoCancel)
If Ans=vbYes then
rngA.select
else
exit sub
end if
else .....
 

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