Using Cell Value to Determine Which Macro To Run

  • Thread starter Thread starter Jayhawktc
  • Start date Start date
J

Jayhawktc

I have two macros that are simple cut and past macros and I would lik
to use a particular cell value to determine which one to run. If th
cell value equals SPR then run Macro 1 if that same cell equals Rebat
then run Macro 2. Any suggestions would be appreciated...Thanks i
advance
 
If you name your cell "example"..

if range("example").value = "SPR" then call macro1
if range("example").value = "REBATE" then call macro2

If your cell is not named, then just use the normal row/colum
reference. For example, if the determining cell is A3...

if range("A3").value = "SPR" then call macro1
if range("A3").value = "REBATE" then call macro2

-gitcyphe
 
One way:-

Sub WhatDoIDo()

If Range("A1") = "SPR" Then
Do this.....
ElseIf Range("A1") = "Rebate" Then
Do this.....
Else: MsgBox "Something Screwed here!!!"
End If

End Sub


More generally:-

Sub WhatDoIDo()

ANS = Range("A1").Value

Select Case ANS
Case "SPR"
Range("B1") = 5
Case "Rebate"
Range("B1") = 10
Case Else
MsgBox "Oops"
End Select

End Sub

or

Sub WhatDoIDo()

ANS = Range("A1").Value
Select Case ANS
Case "SPR": Range("B1") = 5
Case "Rebate": Range("B1") = 10
Case Else: MsgBox "Oops"
End Select

End Sub
 

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

Back
Top