Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default using worksheet name to find cell in table of contents.

Hi,

I have a workbook with about 40 sheets. The first sheet (a
summary/contents page) has a list with hyperlinks to individual sheets
(named 1 through 38). The list can be sorted a number of ways so that
a return hyperlink from the individual sheet does not always go to the
relevant cell on the first sheet (because of any sorting done after
the link was created). Now my sheets are named 1 to 38 and these
correspond to the list in the first sheet(ie: 38 lines of data). What
I was hoping for was a macro that I could use from the individual
sheets that would recognise the sheet name, say, 25 and then go to the
cell containing 25 in the list on the first sheet, which is by the way
called "list"?

Thanks for any help you can provide.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default using worksheet name to find cell in table of contents.

How about

Sub TestMe()

Dim shtname As String

shtname = ActiveSheet.Name
Application.Goto Reference:="list"

Selection.Find(What:=shtname, After:=ActiveCell _
, LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByColumns _
, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate

ActiveCell.Select

End Sub

Regards
Rowan

"RogueSwan" wrote:

Hi,

I have a workbook with about 40 sheets. The first sheet (a
summary/contents page) has a list with hyperlinks to individual sheets
(named 1 through 38). The list can be sorted a number of ways so that
a return hyperlink from the individual sheet does not always go to the
relevant cell on the first sheet (because of any sorting done after
the link was created). Now my sheets are named 1 to 38 and these
correspond to the list in the first sheet(ie: 38 lines of data). What
I was hoping for was a macro that I could use from the individual
sheets that would recognise the sheet name, say, 25 and then go to the
cell containing 25 in the list on the first sheet, which is by the way
called "list"?

Thanks for any help you can provide.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default using worksheet name to find cell in table of contents.

In general, it is bad programming practice to use the Acitvate
(or Select) method in a Find method. The reason is that the code
will fail if the target value is not found. It is better to write
the code in a fashion similar to the following:

Dim FoundCell As Range
Set FoundCell = Selection.Find(....)
If FoundCell Is Nothing Then
' not found, take apporpriate action
Else
' found, take appropriate action
FoundCell.Select
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com






"Rowan" wrote in message
...
How about

Sub TestMe()

Dim shtname As String

shtname = ActiveSheet.Name
Application.Goto Reference:="list"

Selection.Find(What:=shtname, After:=ActiveCell _
, LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByColumns _
, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate

ActiveCell.Select

End Sub

Regards
Rowan

"RogueSwan" wrote:

Hi,

I have a workbook with about 40 sheets. The first sheet (a
summary/contents page) has a list with hyperlinks to
individual sheets
(named 1 through 38). The list can be sorted a number of ways
so that
a return hyperlink from the individual sheet does not always
go to the
relevant cell on the first sheet (because of any sorting done
after
the link was created). Now my sheets are named 1 to 38 and
these
correspond to the list in the first sheet(ie: 38 lines of
data). What
I was hoping for was a macro that I could use from the
individual
sheets that would recognise the sheet name, say, 25 and then
go to the
cell containing 25 in the list on the first sheet, which is by
the way
called "list"?

Thanks for any help you can provide.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default using worksheet name to find cell in table of contents.

Thanks Chip - point taken!

"Chip Pearson" wrote:

In general, it is bad programming practice to use the Acitvate
(or Select) method in a Find method. The reason is that the code
will fail if the target value is not found. It is better to write
the code in a fashion similar to the following:

Dim FoundCell As Range
Set FoundCell = Selection.Find(....)
If FoundCell Is Nothing Then
' not found, take apporpriate action
Else
' found, take appropriate action
FoundCell.Select
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com






"Rowan" wrote in message
...
How about

Sub TestMe()

Dim shtname As String

shtname = ActiveSheet.Name
Application.Goto Reference:="list"

Selection.Find(What:=shtname, After:=ActiveCell _
, LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByColumns _
, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate

ActiveCell.Select

End Sub

Regards
Rowan

"RogueSwan" wrote:

Hi,

I have a workbook with about 40 sheets. The first sheet (a
summary/contents page) has a list with hyperlinks to
individual sheets
(named 1 through 38). The list can be sorted a number of ways
so that
a return hyperlink from the individual sheet does not always
go to the
relevant cell on the first sheet (because of any sorting done
after
the link was created). Now my sheets are named 1 to 38 and
these
correspond to the list in the first sheet(ie: 38 lines of
data). What
I was hoping for was a macro that I could use from the
individual
sheets that would recognise the sheet name, say, 25 and then
go to the
cell containing 25 in the list on the first sheet, which is by
the way
called "list"?

Thanks for any help you can provide.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default using worksheet name to find cell in table of contents.

This should work. add some error trapping.

Sub gotolist()

For Each cell In Sheets("list").Range("a1:a10")

If cell.Value = ActiveSheet.Name Then
MsgBox cell.AddressLocal

x = cell.Address


End If

Next cell

Sheets("list").Range(x).Select

End Sub


Cesar Zapata



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
Can you print a table of contents of all worksheet tabs in a work? Danomcman Excel Discussion (Misc queries) 0 July 28th 09 11:49 PM
Find contents of the last cell in a row OCONUS Excel Worksheet Functions 4 September 18th 06 09:37 PM
How can I list worksheet tabs as a table of contents? aellorac Excel Worksheet Functions 3 August 16th 06 12:10 AM
Create automatic table of contents using worksheet labels Alexandre Excel Discussion (Misc queries) 2 June 2nd 05 10:08 PM
Find cell contents in range Nigel Excel Discussion (Misc queries) 7 May 16th 05 01:15 PM


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

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"