if macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

cell a1 can have to possible values, 1 or 2. if a1=1, when i hit a button i want macro1 to go. if a1=2, when i hit the same button i want macro2 to go. is this possible?
 
Tie Macro1 to the button

Sub Macro1()
If Activesheet.Range("A1").Value =1 Then
Macro2
ElseIf Activesheet.Range("A1").Value = 2 Then
Macro3
End If
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

choice said:
cell a1 can have to possible values, 1 or 2. if a1=1, when i hit a button
i want macro1 to go. if a1=2, when i hit the same button i want macro2 to
go. is this possible?
 
An easy way is to call the same macro and test for 1 or 2 in this cell and
continue execution accordingly.

If Range("A1") = 1 then
macro1
ElseIf Range("A1") = 2 then
macro2
Else
MsgBox "A1 must be 1 or 2"
End If

TH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top