Macro: If a1 is blank, run macro X, else do nothing

oliviar

Board Regular
Joined
Sep 12, 2010
Messages
184
I am trying to get my macro to do this on open. Check if a1 is empty, if its empty run another macro (which is an input box to put something IN a1), but if A1 has something in it, DO NOTHING.

I keep getting errors, saying I'm not formulating my if statements correctly. :confused:

This is what I have:
Code:
Private Sub Workbook_Open()
If Range("a1") = "" Then macrox
else do nothing
End If
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
try..

Code:
'Thisworkbook code
Private Sub Workbook_Open()
try1
End Sub
'standard module code
sub try1
If Range("a1").value = "" Then
macrox ' your macro
else 
exit sub 'do nothing
End If
end sub
 

oliviar

Board Regular
Joined
Sep 12, 2010
Messages
184
Pedie you are a legend, and your dog is adorable.
But why did it hate me the first time? I thought I did it right :'(
 

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Pedie you are a legend, and your dog is adorable.
But why did it hate me the first time? I thought I did it right :'(

Guys please help i dont fully understand what this sentence suppose to mean:biggrin:
'm english learner:ROFLMAO:
I can put in the inputbox but not sure what you want the input value to be like and wat u want to do with the value inputed so...
 

oliviar

Board Regular
Joined
Sep 12, 2010
Messages
184
No problems. It worked great. I was just wondering why it didn't work. :biggrin:
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,196
Messages
5,857,880
Members
431,905
Latest member
RW11700

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
Top