Disable a macro

loubeelou

New Member
Joined
Nov 23, 2009
Messages
32
Is there a way i can disable a macro if a cell isn't filled in? So that the button just won't press if there's no information in a specific cell?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi and welcome to the board!!
Why not just Exit the Macro if that cell is null
Code:
If Range("$A$1") = "" Then 
   MsgBox "You must enter data in $A$1!!!"
   Range("$A$1").Select
   Exit Sub
End If

lenze
 
Last edited:
Upvote 0
okay that sounds great, thankyou! i'm really not familiar with visual basic, so i just have no idea!
 
Upvote 0
You could just pop something like this at the start of the sub:

Code:
If Sheets("Sheet1").Range("A1") = "" Then Exit Sub

Dom
 
Upvote 0
you seem quite familiar with Visual basic, is it similar to other programming languages? i'm doing pascal in my computing lessons, and bits look familiar, does it work in the same sort of way?
 
Upvote 0
I have tried using this code for my spreadsheet, which is similar to my friends above. However, when i then use the macro, it then comes up with "Compile Error, Invalid Outside Procedure". HELP???
 
Upvote 0
Hi Emily: Can you post your code so we can see what may be causing this error? What do you need to do?
lenze
 
Upvote 0

Forum statistics

Threads
1,223,099
Messages
6,170,114
Members
452,302
Latest member
TaMere

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