Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi all,
I need some help on the following. Assuming on sheet 1 in a workbook, in column A2 to A30, i have the sheet names listed in each cell, how am i able to write a macro when i selection the cell directly next to it eg B2, to automatically jump to and select sheet 2 in my workbook. Thank you in advance for any help rendered. Rgds Ray |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Either use a formula in B2 to B30
=HYPERLINK("#"&CELL("address",INDIRECT(A2 & "!A1")),"Goto") OR if you have data in colB; try the below worksheet event..Select the sheet tab which you want to work with. Right click the sheet tab and click on 'View Code'. This will launch VBE. Paste the below code to the right blank portion. Get back to workbook and try out. Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Count = 1 Then If Not Application.Intersect(Target, Range("B2:B30")) Is Nothing Then If SheetExists(CStr(Target.Offset(, -1))) Then Application.EnableEvents = False Sheets(CStr(Target.Offset(, -1))).Activate Application.EnableEvents = True End If End If End If End Sub Function SheetExists(strSheet As String) As Boolean Dim ws As Worksheet On Error Resume Next Set ws = Sheets(strSheet) If Not ws Is Nothing Then SheetExists = True End Function "swiftcode" wrote: Hi all, I need some help on the following. Assuming on sheet 1 in a workbook, in column A2 to A30, i have the sheet names listed in each cell, how am i able to write a macro when i selection the cell directly next to it eg B2, to automatically jump to and select sheet 2 in my workbook. Thank you in advance for any help rendered. Rgds Ray |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi Jackpot,
Thank you, your macro is exactly what i was looking for. Rgds Ray "Jackpot" wrote: Either use a formula in B2 to B30 =HYPERLINK("#"&CELL("address",INDIRECT(A2 & "!A1")),"Goto") OR if you have data in colB; try the below worksheet event..Select the sheet tab which you want to work with. Right click the sheet tab and click on 'View Code'. This will launch VBE. Paste the below code to the right blank portion. Get back to workbook and try out. Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Count = 1 Then If Not Application.Intersect(Target, Range("B2:B30")) Is Nothing Then If SheetExists(CStr(Target.Offset(, -1))) Then Application.EnableEvents = False Sheets(CStr(Target.Offset(, -1))).Activate Application.EnableEvents = True End If End If End If End Sub Function SheetExists(strSheet As String) As Boolean Dim ws As Worksheet On Error Resume Next Set ws = Sheets(strSheet) If Not ws Is Nothing Then SheetExists = True End Function "swiftcode" wrote: Hi all, I need some help on the following. Assuming on sheet 1 in a workbook, in column A2 to A30, i have the sheet names listed in each cell, how am i able to write a macro when i selection the cell directly next to it eg B2, to automatically jump to and select sheet 2 in my workbook. Thank you in advance for any help rendered. Rgds Ray |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I stop automatic selection of cells in Excel? | Excel Discussion (Misc queries) | |||
Automatic Selection of Multiple Rows | Excel Worksheet Functions | |||
Turn off Automatic Selection of Multiple cells. | Excel Discussion (Misc queries) | |||
Automatic selection | Excel Discussion (Misc queries) | |||
automatic font selection | New Users to Excel |