Run macro based on cell conditions

MarcDenney

New Member
Joined
Jun 15, 2011
Messages
43
Hi All,

i have 2 tabs of data and a macro that uses data from both of them.

Basically i need some code to check that the data has been entered.

For Example:

select sheet 1, check that cell B2 contains "Batch number", if it doesn't display error message, if it does then move on to:

select sheet 2, check that cell B1 contains "Account no", if it doesn't display error message, if it does then move on to running main macro.

Any help would be greatly appreciated.

Thanks

Marc
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Try like this

Code:
If Sheets("Sheet1").Range("B2").Value <> "Batch number" Then
    MsgBox "your message here"
    Exit Sub
End If
If Sheets("Sheet2").Range("B1").Value <> "Account no" Then
    MsgBox "your message here"
    Exit Sub
End If
'
'rest of code
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,159
Members
452,892
Latest member
yadavagiri

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top