View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default 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