Code to not run rest of macro if specific value in cell, error check

Craig13_13

New Member
Joined
Apr 9, 2009
Messages
21
Hi all

I have a cell built into my spreadsheet that serves as an error check (i.e. returns the word 'ERROR' if certain criteria are fulfilled on the spreadsheet).
I'm trying to write something into a Macro that will check this cell and not allow it to run if it states ERROR, returning a dialog box to notify this, is this possible?

Thanks in advance
Craig
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi Craig,

I think you just need something simple like this. This will check the active cell...........So if this is not where you want it to check for error you will need to change this to suit

Sub ERRORCHECK()
If ActiveCell = "ERROR" Then
MsgBox "Error found. Exiting Macro"
Exit Sub
Else
MsgBox "MACRO WILL RUN OK"
'Enter existing macro code here
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,692
Members
449,117
Latest member
Aaagu

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