![]() |
ERROR Checking Before Running Program
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 |
ERROR Checking Before Running Program
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 ..... "Paul Black" wrote: 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 |
All times are GMT +1. The time now is 07:14 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com