A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

automatic sheet selection



 
 
Thread Tools Display Modes
  #1  
Old June 4th, 2010, 07:58 AM posted to microsoft.public.excel.misc
swiftcode
external usenet poster
 
Posts: 8
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  
Old June 4th, 2010, 08:30 AM posted to microsoft.public.excel.misc
Jackpot
external usenet poster
 
Posts: 28
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  
Old June 4th, 2010, 09:02 AM posted to microsoft.public.excel.misc
swiftcode
external usenet poster
 
Posts: 8
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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:47 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.