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:
 

Some videos you may like

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

tactps

Well-known Member
Joined
Jan 20, 2004
Messages
3,459
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
 

Watch MrExcel Video

Forum statistics

Threads
1,119,271
Messages
5,577,124
Members
412,769
Latest member
VK12345
Top