Macrp to goto sheet when i click on a cell

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,210
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi everyone,

I have a list of my sheets down sheet "Welcome" Range C7:C200

I
I'd like a macro that when i click on the cell it takes me to that sheet name.

please help if you can.

Thanks

Tony
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
This script will do what you want. I set it to work from C7 to the last row in column C with data
I also set it to where you have to double click on the cell. Just selecting the cell can be a problem if you accidently click on the cell. It's hard to accidently double click on a cell.

And the script will always take to you to Range("A1") on the sheet.

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window


Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified 3-7-18 5:40 AM EST
Dim Lastrow As Long
On Error GoTo M
Lastrow = Cells(Rows.Count, "C").End(xlUp).Row
If Not Intersect(Target, Range("C7:C" & Lastrow)) Is Nothing Then
Cancel = True
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim ans As String
ans = Target.Value
Application.Goto Sheets(ans).Range("A1"), True
End If
Exit Sub
M:
MsgBox "The sheet " & Target.Value & "  Does not exist"
End Sub
 
Last edited:
Upvote 0
Hello Tony,

Place the following code into the "Welcome" sheet module:-

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

If Intersect(Target, Columns(3)) Is Nothing Then Exit Sub 'You could change Columns(3) to Range("C7:C200")to hardcode the macro.
If Target.Count > 1 Then Exit Sub

Sheets(Target.Value).Select

End Sub

Double click on a sheet name and the code will take you directly to that sheet.

I hope that this helps.

Cheerio,
vcoolio.
 
Upvote 0
Hi And the Answer Is, that's great thank you.

VCoolio, thank you very much I've now gone from no options to two options both are great

Thanks very much for your help

Tony
 
Upvote 0
Glad I was able to help you.
Come back here to Mr. Excel next time you need additional assistance.
 
Upvote 0
No worries Tony. I'm glad that I was able to help in some way.

Cheerio,
vcoolio.
 
Upvote 0

Forum statistics

Threads
1,223,577
Messages
6,173,162
Members
452,503
Latest member
AM74

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