ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Navigating among worksheets (https://www.excelbanter.com/excel-programming/320317-navigating-among-worksheets.html)

Phil Hageman[_4_]

Navigating among worksheets
 
I need macro code to do the following: User clicks on a cell in a master
worksheet and is taken to cell A1 in another worksheet. For example:

Click
Cell Worksheet
----- -------------
B14 Atlanta
B15 Philadelphia
B16 Jacksonville
Etc.

There are thirty different click cells on the master worksheet and thirty
different target worksheets.

Thanks, Phil



Gary Brown[_5_]

Navigating among worksheets
 
Create hyperlinks in the 'click Cell's.
INSERT / HYPERLINK
Select 'Place in this document' in the box on the left
Select the sheet you want the hyperlink to point to.
Done

HTH,
Gary Brown



"Phil Hageman" wrote:

I need macro code to do the following: User clicks on a cell in a master
worksheet and is taken to cell A1 in another worksheet. For example:

Click
Cell Worksheet
----- -------------
B14 Atlanta
B15 Philadelphia
B16 Jacksonville
Etc.

There are thirty different click cells on the master worksheet and thirty
different target worksheets.

Thanks, Phil



Tom Ogilvy

Navigating among worksheets
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sh as Worksheet
if Target.count 1 then exit sub
If Target.Column = 2 Then
If Target.Row =14 and Target.Row <= 43 Then
on Error Resume next
set sh = Worksheets(Target.offset(0,1).Value)
On error goto 0
if not sh is nothing then
sh.Activate
sh.Range("A1").Select
End if
End If
End If
End Sub


--
Regards,
Tom Ogilvy


"Phil Hageman" wrote in message
...
I need macro code to do the following: User clicks on a cell in a master
worksheet and is taken to cell A1 in another worksheet. For example:

Click
Cell Worksheet
----- -------------
B14 Atlanta
B15 Philadelphia
B16 Jacksonville
Etc.

There are thirty different click cells on the master worksheet and thirty
different target worksheets.

Thanks, Phil





Phil Hageman[_4_]

Navigating among worksheets
 
Tom, Thanks for your reply. For some reason, the macro doesnt work €“ no
error though. I have requested this macro in the early stages of development
of this project, anticipating the need to quickly navigate the user through
all the worksheets. Two things come to mind:
1.) Not all of the target worksheets have been added yet. Additionally, I
may have to add or delete worksheets (cities) as things progress, which would
have their corresponding click cell.
2.) The click cells on the master worksheet (named €śActions€ť) are not
necessarily consecutive, as in the example below.

Click Target
Cell Worksheet
------ ------------
B11 Atlanta
B12 Philadelphia
B14 Jacksonville
B16 Miami
B17 Montgomery
B18 Columbus
B23 Indianapolis

Should the code be looking for the title of the worksheet and then acting on
it?


"Tom Ogilvy" wrote:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sh as Worksheet
if Target.count 1 then exit sub
If Target.Column = 2 Then
If Target.Row =14 and Target.Row <= 43 Then
on Error Resume next
set sh = Worksheets(Target.offset(0,1).Value)
On error goto 0
if not sh is nothing then
sh.Activate
sh.Range("A1").Select
End if
End If
End If
End Sub


--
Regards,
Tom Ogilvy


"Phil Hageman" wrote in message
...
I need macro code to do the following: User clicks on a cell in a master
worksheet and is taken to cell A1 in another worksheet. For example:

Click
Cell Worksheet
----- -------------
B14 Atlanta
B15 Philadelphia
B16 Jacksonville
Etc.

There are thirty different click cells on the master worksheet and thirty
different target worksheets.

Thanks, Phil






Lonnie M.

Navigating among worksheets
 
Hi, if the user double clicks in the cell you could use something like
this to take them to that sheet (assuming that the sheets are named
after the cities; place this in the sheet module):
Public Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range,
Cancel As Boolean)
Dim C$
Cancel = True
C = Target.Address(False, False)
If C = "B11" Then
Worksheets("Atlanta").Select
ElseIf C = "B12" Then
Worksheets("Philadelphia").Select
ElseIf C = "B14" Then
Worksheets("Jacksonville").Select
ElseIf C = "B16" Then
Worksheets("Miami").Select
ElseIf C = "B17" Then
Worksheets("Montgomery").Select
ElseIf C = "B18" Then
Worksheets("Columbus").Select
ElseIf C = "B23" Then
Worksheets("Indianapolis").Select
End If
End Sub


HTH--Lonnie M.


Phil Hageman[_4_]

Navigating among worksheets
 
Thanks, Lonnie - it works.

"Lonnie M." wrote:

Hi, if the user double clicks in the cell you could use something like
this to take them to that sheet (assuming that the sheets are named
after the cities; place this in the sheet module):
Public Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range,
Cancel As Boolean)
Dim C$
Cancel = True
C = Target.Address(False, False)
If C = "B11" Then
Worksheets("Atlanta").Select
ElseIf C = "B12" Then
Worksheets("Philadelphia").Select
ElseIf C = "B14" Then
Worksheets("Jacksonville").Select
ElseIf C = "B16" Then
Worksheets("Miami").Select
ElseIf C = "B17" Then
Worksheets("Montgomery").Select
ElseIf C = "B18" Then
Worksheets("Columbus").Select
ElseIf C = "B23" Then
Worksheets("Indianapolis").Select
End If
End Sub


HTH--Lonnie M.



Tom Ogilvy

Navigating among worksheets
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sh as Worksheet
if Target.count 1 then exit sub
If Target.Column = 1 Then
on Error Resume next
set sh = Worksheets(Target.offset(0,1).Value)
On error goto 0
if not sh is nothing then
sh.Activate
sh.Range("A1").Select
End if
End If
End Sub

Misunderstood your post.

It worked a couple of days ago when I responded to your post then and I have
taken out my modifications, so it works now as well.

--
Regards,
Tom Ogilvy


"Phil Hageman" wrote in message
...
Tom, Thanks for your reply. For some reason, the macro doesn't work - no
error though. I have requested this macro in the early stages of

development
of this project, anticipating the need to quickly navigate the user

through
all the worksheets. Two things come to mind:
1.) Not all of the target worksheets have been added yet. Additionally, I
may have to add or delete worksheets (cities) as things progress, which

would
have their corresponding click cell.
2.) The click cells on the master worksheet (named "Actions") are not
necessarily consecutive, as in the example below.

Click Target
Cell Worksheet
------ ------------
B11 Atlanta
B12 Philadelphia
B14 Jacksonville
B16 Miami
B17 Montgomery
B18 Columbus
B23 Indianapolis

Should the code be looking for the title of the worksheet and then acting

on
it?


"Tom Ogilvy" wrote:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sh as Worksheet
if Target.count 1 then exit sub
If Target.Column = 2 Then
If Target.Row =14 and Target.Row <= 43 Then
on Error Resume next
set sh = Worksheets(Target.offset(0,1).Value)
On error goto 0
if not sh is nothing then
sh.Activate
sh.Range("A1").Select
End if
End If
End If
End Sub


--
Regards,
Tom Ogilvy


"Phil Hageman" wrote in message
...
I need macro code to do the following: User clicks on a cell in a

master
worksheet and is taken to cell A1 in another worksheet. For example:

Click
Cell Worksheet
----- -------------
B14 Atlanta
B15 Philadelphia
B16 Jacksonville
Etc.

There are thirty different click cells on the master worksheet and

thirty
different target worksheets.

Thanks, Phil








Tom Ogilvy

Navigating among worksheets
 
One more try. Your original post (not today) was clicking in column A and
going to the worksheet in column B. So my macro reflected that. i have now
modified it for clicking on the name of the sheet itself with the assumption
the cell with the name is in column B.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sh As Worksheet
If Target.Count 1 Then Exit Sub
If Target.Column = 2 Then
On Error Resume Next
Set sh = Worksheets(Target.Value)
On Error GoTo 0
If Not sh Is Nothing Then
sh.Activate
sh.Range("A1").Select
End If
End If
End Sub

If this doesn't work then I guess I don't understand what you want.

--
Regards,
Tom Ogilvy



"Tom Ogilvy" wrote in message
...
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sh as Worksheet
if Target.count 1 then exit sub
If Target.Column = 1 Then
on Error Resume next
set sh = Worksheets(Target.offset(0,1).Value)
On error goto 0
if not sh is nothing then
sh.Activate
sh.Range("A1").Select
End if
End If
End Sub

Misunderstood your post.

It worked a couple of days ago when I responded to your post then and I

have
taken out my modifications, so it works now as well.

--
Regards,
Tom Ogilvy


"Phil Hageman" wrote in message
...
Tom, Thanks for your reply. For some reason, the macro doesn't work -

no
error though. I have requested this macro in the early stages of

development
of this project, anticipating the need to quickly navigate the user

through
all the worksheets. Two things come to mind:
1.) Not all of the target worksheets have been added yet. Additionally,

I
may have to add or delete worksheets (cities) as things progress, which

would
have their corresponding click cell.
2.) The click cells on the master worksheet (named "Actions") are not
necessarily consecutive, as in the example below.

Click Target
Cell Worksheet
------ ------------
B11 Atlanta
B12 Philadelphia
B14 Jacksonville
B16 Miami
B17 Montgomery
B18 Columbus
B23 Indianapolis

Should the code be looking for the title of the worksheet and then

acting
on
it?


"Tom Ogilvy" wrote:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sh as Worksheet
if Target.count 1 then exit sub
If Target.Column = 2 Then
If Target.Row =14 and Target.Row <= 43 Then
on Error Resume next
set sh = Worksheets(Target.offset(0,1).Value)
On error goto 0
if not sh is nothing then
sh.Activate
sh.Range("A1").Select
End if
End If
End If
End Sub


--
Regards,
Tom Ogilvy


"Phil Hageman" wrote in

message
...
I need macro code to do the following: User clicks on a cell in a

master
worksheet and is taken to cell A1 in another worksheet. For

example:

Click
Cell Worksheet
----- -------------
B14 Atlanta
B15 Philadelphia
B16 Jacksonville
Etc.

There are thirty different click cells on the master worksheet and

thirty
different target worksheets.

Thanks, Phil










Phil Hageman[_4_]

Navigating among worksheets
 
Tom, This works! When the user clicks a cell, the macro works to find a
worksheet with the same name as the cell clicked on...right? The restriction
in this macro is that the "click" cell must be in the second column...true?
Thanks for taking the time with this.
Phil

"Tom Ogilvy" wrote:

One more try. Your original post (not today) was clicking in column A and
going to the worksheet in column B. So my macro reflected that. i have now
modified it for clicking on the name of the sheet itself with the assumption
the cell with the name is in column B.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sh As Worksheet
If Target.Count 1 Then Exit Sub
If Target.Column = 2 Then
On Error Resume Next
Set sh = Worksheets(Target.Value)
On Error GoTo 0
If Not sh Is Nothing Then
sh.Activate
sh.Range("A1").Select
End If
End If
End Sub

If this doesn't work then I guess I don't understand what you want.

--
Regards,
Tom Ogilvy



"Tom Ogilvy" wrote in message
...
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sh as Worksheet
if Target.count 1 then exit sub
If Target.Column = 1 Then
on Error Resume next
set sh = Worksheets(Target.offset(0,1).Value)
On error goto 0
if not sh is nothing then
sh.Activate
sh.Range("A1").Select
End if
End If
End Sub

Misunderstood your post.

It worked a couple of days ago when I responded to your post then and I

have
taken out my modifications, so it works now as well.

--
Regards,
Tom Ogilvy


"Phil Hageman" wrote in message
...
Tom, Thanks for your reply. For some reason, the macro doesn't work -

no
error though. I have requested this macro in the early stages of

development
of this project, anticipating the need to quickly navigate the user

through
all the worksheets. Two things come to mind:
1.) Not all of the target worksheets have been added yet. Additionally,

I
may have to add or delete worksheets (cities) as things progress, which

would
have their corresponding click cell.
2.) The click cells on the master worksheet (named "Actions") are not
necessarily consecutive, as in the example below.

Click Target
Cell Worksheet
------ ------------
B11 Atlanta
B12 Philadelphia
B14 Jacksonville
B16 Miami
B17 Montgomery
B18 Columbus
B23 Indianapolis

Should the code be looking for the title of the worksheet and then

acting
on
it?


"Tom Ogilvy" wrote:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sh as Worksheet
if Target.count 1 then exit sub
If Target.Column = 2 Then
If Target.Row =14 and Target.Row <= 43 Then
on Error Resume next
set sh = Worksheets(Target.offset(0,1).Value)
On error goto 0
if not sh is nothing then
sh.Activate
sh.Range("A1").Select
End if
End If
End If
End Sub


--
Regards,
Tom Ogilvy


"Phil Hageman" wrote in

message
...
I need macro code to do the following: User clicks on a cell in a

master
worksheet and is taken to cell A1 in another worksheet. For

example:

Click
Cell Worksheet
----- -------------
B14 Atlanta
B15 Philadelphia
B16 Jacksonville
Etc.

There are thirty different click cells on the master worksheet and

thirty
different target worksheets.

Thanks, Phil











Tom Ogilvy

Navigating among worksheets
 
the click must be in column B. That was my understanding of the revised
requirement. If the requirement is different, then state what the
requirement is.

When the user clicks a cell, the macro works to find a
worksheet with the same name as the cell clicked on...right?


Answer: Yes

The restriction
in this macro is that the "click" cell must be in the second

column...true?

Answer: True

--
Regards,
Tom Ogilvy


"Phil Hageman" wrote in message
...
Tom, This works! When the user clicks a cell, the macro works to find a
worksheet with the same name as the cell clicked on...right? The

restriction
in this macro is that the "click" cell must be in the second

column...true?
Thanks for taking the time with this.
Phil

"Tom Ogilvy" wrote:

One more try. Your original post (not today) was clicking in column A

and
going to the worksheet in column B. So my macro reflected that. i have

now
modified it for clicking on the name of the sheet itself with the

assumption
the cell with the name is in column B.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sh As Worksheet
If Target.Count 1 Then Exit Sub
If Target.Column = 2 Then
On Error Resume Next
Set sh = Worksheets(Target.Value)
On Error GoTo 0
If Not sh Is Nothing Then
sh.Activate
sh.Range("A1").Select
End If
End If
End Sub

If this doesn't work then I guess I don't understand what you want.

--
Regards,
Tom Ogilvy



"Tom Ogilvy" wrote in message
...
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sh as Worksheet
if Target.count 1 then exit sub
If Target.Column = 1 Then
on Error Resume next
set sh = Worksheets(Target.offset(0,1).Value)
On error goto 0
if not sh is nothing then
sh.Activate
sh.Range("A1").Select
End if
End If
End Sub

Misunderstood your post.

It worked a couple of days ago when I responded to your post then and

I
have
taken out my modifications, so it works now as well.

--
Regards,
Tom Ogilvy


"Phil Hageman" wrote in

message
...
Tom, Thanks for your reply. For some reason, the macro doesn't

work -
no
error though. I have requested this macro in the early stages of
development
of this project, anticipating the need to quickly navigate the user
through
all the worksheets. Two things come to mind:
1.) Not all of the target worksheets have been added yet.

Additionally,
I
may have to add or delete worksheets (cities) as things progress,

which
would
have their corresponding click cell.
2.) The click cells on the master worksheet (named "Actions") are

not
necessarily consecutive, as in the example below.

Click Target
Cell Worksheet
------ ------------
B11 Atlanta
B12 Philadelphia
B14 Jacksonville
B16 Miami
B17 Montgomery
B18 Columbus
B23 Indianapolis

Should the code be looking for the title of the worksheet and then

acting
on
it?


"Tom Ogilvy" wrote:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sh as Worksheet
if Target.count 1 then exit sub
If Target.Column = 2 Then
If Target.Row =14 and Target.Row <= 43 Then
on Error Resume next
set sh = Worksheets(Target.offset(0,1).Value)
On error goto 0
if not sh is nothing then
sh.Activate
sh.Range("A1").Select
End if
End If
End If
End Sub


--
Regards,
Tom Ogilvy


"Phil Hageman" wrote in

message
...
I need macro code to do the following: User clicks on a cell in

a
master
worksheet and is taken to cell A1 in another worksheet. For

example:

Click
Cell Worksheet
----- -------------
B14 Atlanta
B15 Philadelphia
B16 Jacksonville
Etc.

There are thirty different click cells on the master worksheet

and
thirty
different target worksheets.

Thanks, Phil













Phil Hageman[_4_]

Navigating among worksheets
 
Tom, Thanks for the insight. This is working exactly as I need. Phil

"Tom Ogilvy" wrote:

the click must be in column B. That was my understanding of the revised
requirement. If the requirement is different, then state what the
requirement is.

When the user clicks a cell, the macro works to find a
worksheet with the same name as the cell clicked on...right?


Answer: Yes

The restriction
in this macro is that the "click" cell must be in the second

column...true?

Answer: True

--
Regards,
Tom Ogilvy


"Phil Hageman" wrote in message
...
Tom, This works! When the user clicks a cell, the macro works to find a
worksheet with the same name as the cell clicked on...right? The

restriction
in this macro is that the "click" cell must be in the second

column...true?
Thanks for taking the time with this.
Phil

"Tom Ogilvy" wrote:

One more try. Your original post (not today) was clicking in column A

and
going to the worksheet in column B. So my macro reflected that. i have

now
modified it for clicking on the name of the sheet itself with the

assumption
the cell with the name is in column B.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sh As Worksheet
If Target.Count 1 Then Exit Sub
If Target.Column = 2 Then
On Error Resume Next
Set sh = Worksheets(Target.Value)
On Error GoTo 0
If Not sh Is Nothing Then
sh.Activate
sh.Range("A1").Select
End If
End If
End Sub

If this doesn't work then I guess I don't understand what you want.

--
Regards,
Tom Ogilvy



"Tom Ogilvy" wrote in message
...
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sh as Worksheet
if Target.count 1 then exit sub
If Target.Column = 1 Then
on Error Resume next
set sh = Worksheets(Target.offset(0,1).Value)
On error goto 0
if not sh is nothing then
sh.Activate
sh.Range("A1").Select
End if
End If
End Sub

Misunderstood your post.

It worked a couple of days ago when I responded to your post then and

I
have
taken out my modifications, so it works now as well.

--
Regards,
Tom Ogilvy


"Phil Hageman" wrote in

message
...
Tom, Thanks for your reply. For some reason, the macro doesn't

work -
no
error though. I have requested this macro in the early stages of
development
of this project, anticipating the need to quickly navigate the user
through
all the worksheets. Two things come to mind:
1.) Not all of the target worksheets have been added yet.

Additionally,
I
may have to add or delete worksheets (cities) as things progress,

which
would
have their corresponding click cell.
2.) The click cells on the master worksheet (named "Actions") are

not
necessarily consecutive, as in the example below.

Click Target
Cell Worksheet
------ ------------
B11 Atlanta
B12 Philadelphia
B14 Jacksonville
B16 Miami
B17 Montgomery
B18 Columbus
B23 Indianapolis

Should the code be looking for the title of the worksheet and then
acting
on
it?


"Tom Ogilvy" wrote:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sh as Worksheet
if Target.count 1 then exit sub
If Target.Column = 2 Then
If Target.Row =14 and Target.Row <= 43 Then
on Error Resume next
set sh = Worksheets(Target.offset(0,1).Value)
On error goto 0
if not sh is nothing then
sh.Activate
sh.Range("A1").Select
End if
End If
End If
End Sub


--
Regards,
Tom Ogilvy


"Phil Hageman" wrote in
message
...
I need macro code to do the following: User clicks on a cell in

a
master
worksheet and is taken to cell A1 in another worksheet. For
example:

Click
Cell Worksheet
----- -------------
B14 Atlanta
B15 Philadelphia
B16 Jacksonville
Etc.

There are thirty different click cells on the master worksheet

and
thirty
different target worksheets.

Thanks, Phil















All times are GMT +1. The time now is 03:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com