Need to add If statement in code

MightyQuinn

Board Regular
Joined
Dec 28, 2007
Messages
152
I have this code (which works perfectly), now I want to add in an If statement to it (in red below).

It should check to see IF a cell = "text" then it runs a macro, ELSEIF cell = "other text" it runs another macro and ELSE will do nothing.

Here is my code:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("W39")) Is Nothing Then
On Error GoTo Error:
    Select Case Target.Value
        Case "10 x 10"
        Application.EnableEvents = False
            Macro4
[COLOR="Red"]IF AH15 = "IM130 Rev A"  
Macro5
Elseif AH15= "IM100 Rev B" 
Macro6
Else will do nothing[/COLOR]
            GoTo Finish
        Case "10 x 7.5"
        Application.EnableEvents = False
            Macro1
            GoTo Finish
        Case "10 x 5"
        Application.EnableEvents = False
            Macro2
            GoTo Finish
        Case "10 x 2.5"
        Application.EnableEvents = False
            Macro3
            GoTo Finish
        Case Else
            MsgBox "Unexpected value, please select again."
        Application.EnableEvents = False
            GoTo Finish:
        End Select
    End If
Finish:
    Application.EnableEvents = True
    Exit Sub
Error:
    MsgBox "Macro not found!"
End Sub

Note: Only need to add the code in red. And I have the simple macros working already.
 
Positive, the only thing I just thought of is that AH15 is a merged cell. Does this mean it is a Range now? And should be written differently
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,214,868
Messages
6,122,005
Members
449,059
Latest member
mtsheetz

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