Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default automatic sheet selection

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 46
Default automatic sheet selection

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default automatic sheet selection

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I stop automatic selection of cells in Excel? Sherriff of Nottingham Excel Discussion (Misc queries) 2 December 19th 08 07:48 PM
Automatic Selection of Multiple Rows Emmlie Excel Worksheet Functions 3 August 7th 08 06:43 PM
Turn off Automatic Selection of Multiple cells. klm[_2_] Excel Discussion (Misc queries) 1 December 12th 07 03:38 PM
Automatic selection Bonny Excel Discussion (Misc queries) 2 March 21st 05 02:45 PM
automatic font selection newbie New Users to Excel 1 January 7th 05 09:48 PM


All times are GMT +1. The time now is 05:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"