Hyperlink to highlighted headers

Serafin54

Board Regular
Joined
Apr 11, 2014
Messages
165
Office Version
  1. 2016
Platform
  1. Windows
Hello. Not sure if something like this is even possible but trying to figure something out. I have this code that creates a table of contents with hyperlinks to all tabs in the workbook which is fine except I can't get the "Table of Contents" page to not be included as well as I'd rather not have the sheet name listed twice, one non HL and one HL.

VBA Code:
Dim ws As Worksheet

'color a worksheet, named Sheet1, in green

    Sheets.Add Before:=Sheets(1)
    Sheets(ActiveSheet.Name).Name = "Table of Contents"
    Set ws = Worksheets("Table of Contents")
    ws.Tab.ColorIndex = 4
    
'Add title and formatting

    Range("A2").Select
    Selection.FormulaR1C1 = "Table of Contents"
    Cells.Select
    With Selection.Font
        .Name = "Calibri"
        .FontStyle = "Regular"

    End With
    Range("A3").Select
    With Selection.Font
        .Name = "Calibri"
        .FontStyle = "Bold"
        .Size = 20

    End With
    
    
  ' Add Sheet Names in workbook
    
    Dim x As Integer
    For x = 1 To Worksheets.Count
    Cells(x + 4, 2).Value = Worksheets(x).Name
    Next x
    
' Add hypyerlinks to tabs
    
     Dim LastRowColumnB As Long
       LastRowColumnB = Cells(Rows.Count, 2).End(xlUp).Row
       Range("C5:C" & LastRowColumnB).Formula = "=HYPERLINK(""#'""&RC[-1]&""'!A1"",RC[-1])"
       ActiveSheet.UsedRange.EntireColumn.AutoFit

    
End Sub

What I'm trying to add into it is column for any highlighted headers within the workbook that falls in the sheets listed. I don't know if this is even possible. what i envision is going from this...
TOC.xlsx
ABCDEF
1
2Table of Contents
3
4
5Table of ContentsTable of Contents
6East 54East 54
7South 22South 22
8West 14West 14
9West 21West 21
10
11
12
13
14
15
Current VBA
Cell Formulas
RangeFormula
C5:C9C5=HYPERLINK("#'"&B5&"'!A1",B5)



to this....

TOC.xlsx
ABCDEFG
1
2Table of Contents
3
4Sheet NameDiscrepant ColumnReason
5East 54Eligible
6South 22
7West 14Active
8Tagline
9West 21Description
10Tagline
11Company Email
12Eligible
13Active
14
15
16
Notes



The headers are manually highlighted but color could vary. pick of sample layout attached but header values are random. As I said, I'm not even sure if this is possible so if not, closure works too. lol. Thanks!!!!

TOC.xlsx
ABCDEFG
1SegmentFake Company NameDescriptionTaglineCompany EmailEligibleActive
2West 14Kreiger IncRealigned Discrete ModelGenerate Rich E-Marketsyschimmel@altenwerth.comYesNO
3West 14Dickens, Auer and CasperFully-Configurable Client-Driven AttitudeRecontextualize Viral Initiativessusie.braun@treutel.comYesYes
4West 14Metz LLCMulti-Lateral Discrete Neural-NetSynergize Enterprise Action-Itemsgulgowski.ayla@tillman.comYesYes
5West 14Towne PLCProfit-Focused Bandwidth-Monitored CustomerloyaltyExploit Visionary E-Tailersschneider.clemmie@marvin.comYesYes
6West 14Dare and SonsDiverse Systemic BlockchainProductize Dynamic Contenteboehm@williamson.comYesYes
7West 14Stokes GroupUpgradable Coherent AccessAggregate Back-End Functionalitiesbaumbach.frankie@okeefe.comYesYes
8West 14Veum IncFunction-Based Eco-Centric OpensystemSeize 24/365 Architecturesoconner.jett@parisian.infoYesYes
9West 14Bruen GroupFacetoface Assymetric Initiativeaurelio.barton@bins.orgYesYes
10West 14Hettinger-HegmannOperative Well-Modulated AllianceSynergize Frictionless Bandwidthabernathy.alfredo@altenwerth.comYesYes
11West 14Cremin LtdMulti-Tiered Coherent ProductBenchmark Cutting-Edge Partnershipsthompson.cruz@swift.bizYesYes
12West 14Miller-KemmerOrganic Homogeneous StructureUtilize Rich Metricshayley.anderson@emard.comYesYes
13West 14Huel LtdReactive Fault-Tolerant AccessMonetize User-Centric Applicationsefrain58@boyle.orgYesYes
14West 14Romaguera-WuckertFuture-Proofed Mobile SolutionRepurpose Sexy Experienceshouston97@lynch.comYesYes
15West 14Langworth, Rohan and SwaniawskiAdaptive Responsive EncodingSynthesize Cutting-Edge Webservicesfreda97@reichel.orgYesYes
16West 14Gorczany-HaleyFront-Line Transitional ProjectionFacilitate Visionary E-Commerceshodkiewicz@ondricka.comYesYes
17West 14Schoen, Schmitt and LoweVision-Oriented Empowering MiddlewareSynergize Sticky Experiencesnzulauf@hill.orgYesYes
18West 14Mraz-WillQuality-Focused Demand-Driven DatabaseDisintermediate Plug-And-Play Usersftreutel@harber.orgYesYes
West 14
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
It is very easy to get rid of the "table of contents by changing thise two lines:
VBA Code:
  ' Add Sheet Names in workbook
   
    Dim x As Integer
    For x = 2 To Worksheets.Count   ' change start to 2
    Cells(x + 3, 2).Value = Worksheets(x).Name   ' change to x+3
    Next x
The second part of your problem brings in someting totally different so I wouldn't start from your current code. One of the real difficulties is working out how you are going to detect whether a header is highlighted, specially if the color changes
 
Upvote 0
ah ok. that makes sense to make that change. thanks.

I had a feeling it wouldn't be a simple add to in order to get that info. For the highlighting i was thinking of something like "If Not cell.Interior.ColorIndex = 0 Then" statement for row 1 on each sheet. Though i'm kind of bumping around on this so not sure that's feesable.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top