Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automatic creation of Hyperlinks

Hi there

Wondering if someone has a macro which scans through all cells in all
worksheets and if it finds a cell which has the same value of one of
the sheet names, it then converts that cell to a hyperlink to that
sheet.
For example, assume you have sheets names Sales, COS and GP and in the
sheet Sales, cell A3 contains the text COS. It should then make this a
hyperlink to the COS sheet.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default Automatic creation of Hyperlinks

Zunaid

Try this

Sub MakeHLinks()

Dim sh As Worksheet
Dim ThisSheet As Worksheet
Dim rFound As Range
Dim sFirstAdd As String

'identify the sheet on which the links will go
Set ThisSheet = ThisWorkbook.Sheets("Other")

'loop through the worksheets
For Each sh In ThisWorkbook.Worksheets
'skip the sheet identified
If sh.Name < ThisSheet.Name Then
'find the first cell with a sheetname
Set rFound = ThisSheet.UsedRange.Find(sh.Name, , xlValues,
xlWhole)

'If a cell was found
If Not rFound Is Nothing Then
'store the address of the first cell found
sFirstAdd = rFound.Address

Do 'until the found cell is the first cell found
'add the hyperlink
rFound.Hyperlinks.Add rFound, "", sh.Name & "!A1"
'find the next cell with the sheetname
Set rFound = ThisSheet.UsedRange.FindNext(rFound)
'stop looping when the FindNext gets back to the first
'cell found
Loop Until rFound.Address = sFirstAdd
End If
End If
Next sh

End Sub

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"Zunaid" wrote in message
om...
Hi there

Wondering if someone has a macro which scans through all cells in all
worksheets and if it finds a cell which has the same value of one of
the sheet names, it then converts that cell to a hyperlink to that
sheet.
For example, assume you have sheets names Sales, COS and GP and in the
sheet Sales, cell A3 contains the text COS. It should then make this a
hyperlink to the COS sheet.

Thanks



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
Suppress automatic formula creation? Geoff C Excel Worksheet Functions 2 March 28th 07 08:46 AM
Automatic creation of worksheets dave Excel Worksheet Functions 2 March 15th 07 05:03 PM
Automatic Data Validation drop down creation Buddhapenguin Excel Discussion (Misc queries) 1 May 12th 05 08:41 PM
Automatic Number Creation Problem? Corp Excel Worksheet Functions 1 April 6th 05 06:19 AM
Automatic creation of an overview using several workbooks Chris Excel Programming 0 February 5th 04 07:03 PM


All times are GMT +1. The time now is 10:38 PM.

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

About Us

"It's about Microsoft Excel"