hi all,
I know almost nothing about VBA, but I'm trying to run a macro (which I registered and works fine) every time the text in a specific cell changes. ultimately, I'd like to have something like this:
if "a1" text is "uk" then run macro1
if "a1" text is "de" then run macro2
etc.
I somehow managed to make it happen whenever I change the cell content, but I'm not able to make it run by a specific text. see below the code I currently have:
Sub uk()
Columns("A:b").Select
Selection.sort Key1:=Range("b2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("q1")) Is Nothing Then
If Target.Value = "uk" Then
Application.EnableEvents = False
Application.ScreenUpdating = False
Call uk
Application.EnableEvents = True
Application.ScreenUpdating = True
Else
End If
End Sub
I keep getting an error message which is: compile error, block if without end if.
can anyone please help me!?
thanks!
I know almost nothing about VBA, but I'm trying to run a macro (which I registered and works fine) every time the text in a specific cell changes. ultimately, I'd like to have something like this:
if "a1" text is "uk" then run macro1
if "a1" text is "de" then run macro2
etc.
I somehow managed to make it happen whenever I change the cell content, but I'm not able to make it run by a specific text. see below the code I currently have:
Sub uk()
Columns("A:b").Select
Selection.sort Key1:=Range("b2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("q1")) Is Nothing Then
If Target.Value = "uk" Then
Application.EnableEvents = False
Application.ScreenUpdating = False
Call uk
Application.EnableEvents = True
Application.ScreenUpdating = True
Else
End If
End Sub
I keep getting an error message which is: compile error, block if without end if.
can anyone please help me!?
thanks!