CALL MACRO WHEN... 3 simple problems - simple CODE needed

HELP PLEASE

Board Regular
Joined
Jan 8, 2005
Messages
156
Please help with code...

Problem 1:
If A1="Excel" run Macro1 but if A1 equals anything other than "Excel" run Macro2.

Problem 2:
Run Macro3 the next 3 times the spreadsheet is opened. The 4th time it is opened, Macro3 should not run.

Problem 3:
Macro4 is called to run on the opening of the spreadsheet (it is called in the ThisWorkbook folder). If the calander year equals 2007 I need to prevent Macro4 from running when the document is opened.

Thanks so much! :biggrin:
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I have assumed that you have the dtes, etc in different cells.

Problem 1:
sub CheckIt()
If [a1].value = "Excel" then
Macro1
else
Macro2
end if
end sub

Problem 2:
Private Sub Workbook_Open()
[a1] = [a1] + 1
if [a1] < 4 then Macro3
End Sub

Problem 3:
Private Sub Workbook_Open()
if [b1] <> 2007 then Macro4
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,394
Members
448,957
Latest member
Hat4Life

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