Multiple If statements in one macro

sobeleg

New Member
Joined
Jun 29, 2011
Messages
40
I am try to make it so when a certain number is entered into a box, and a button is clicked, it will take you to a different place depending on what number was entered. I keep getting various errors when writing this in Visual Basic such as "Block If without End If," :End if withou block if" Else without if. and "Run-time error '13': type mismatch."

As of now this is what I have:

Sub Testbutton()
'
' If "D8"=011 Then
' Application.Goto Reference:="R28C1"
' If "D8"=701 Then
' Application.Goto Reference:="R86C1"
' End If
End Sub

Any help would be greatly appreciated.
 
Thank you for all your help. I have one final question. I need to add a second reference on the sheet so it scrolls below the destination and back up to it, so It will work regardless of where the cursor previously was. How do I add that second range to:

Case 11: Application.Goto Reference:="Frozen!R28C1"

I am looking to add R3C1 to the end of this but I am not sure how to.

Thanks
 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,224,566
Messages
6,179,553
Members
452,928
Latest member
101blockchains

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