Else without If

JacMeyers

New Member
Joined
Mar 20, 2015
Messages
2
below is the macro i have but it is coming back with "Else without If" error
I'm trying to create a macro that when a cell = USHMTrig then it takes the user to a certain cell on a particular sheet within the worksheet.

Sub USHMTrigMac()
If L8.Value = USHMTrig Then
Do: Sheets("Example - US").Select
Range("B2").Select
Else
Exit Sub
End If
End Sub

What am I doing wrong?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
use this....
Code:
Sub USHMTrigMac()
Dim USHMTrig As Variant


USHMTrig = "search me"
If Workbooks("Name").Sheets("Name").Range("L8").Value = USHMTrig Then


Sheets("sheet2").Range("B2").Select




Else
Exit Sub
End If
End Sub

if you are using Do loop don't forget to close it.

 
Upvote 0
Hi. I think you are trying to do this:

Code:
Sub USHMTrigMac()
    If Sheets("Sheet1").Range("L8").Value = "USHMTrig" Then
        Sheets("Example - US").Select
        Range("B2").Select
    Else
    End If
End Sub
 
Upvote 0
That helped to end the error message however when I run the macro, it doesn't do anything.
I created this standalone macro which worked...
Sub JumpTo()
'
' JumpTo Macro
'
'
Sheets("Example - US").Select
Range("B2").Select
End Sub

However, I want it to take me there based on the condition that
If Sheets("Sheet1").Range("L8").Value = "USHMTrig" Then

Any ideas?
 
Upvote 0
Code:
Sub JumpTo()

If Sheets("Sheet1").Range("L8") = "USHMTrig" Then
Sheets("Example - US").Select
Range("B2").Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,122
Members
452,381
Latest member
Nova88

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