+ Reply to Thread
Results 1 to 3 of 3

Excel 2010 Create a macro to check if cell contains hyperlink then apply hyperlink style

Hybrid View

  1. #1
    Registered User
    Join Date
    07-01-2010
    Location
    Israel
    MS-Off Ver
    Excel 2010
    Posts
    3

    Excel 2010 Create a macro to check if cell contains hyperlink then apply hyperlink style

    I have a worksheet with about 1800 rows and multiple columns. In one particular column, the cell MAY contain a hyperlink. I accidentally removed the hyperlink style (by trying to get rid of a conditional formatting rule ) and now all the cells in the column have the same plain formatting whether they contain a hyperlink or not. Instead of formatting each cell individually, can I create a macro that will check if the cell contains a hyperlink and if so, apply the hyperlink style? How do I do this?
    Thank you.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Excel 2010 Create a macro to check if cell contains hyperlink then apply hyperlink sty

    try this

    Sub X()
    
        Dim rngHLs As Range
        Dim objHL As Hyperlink
        
        For Each objHL In ActiveSheet.Hyperlinks
            If rngHLs Is Nothing Then
                Set rngHLs = objHL.Range
            Else
                Set rngHLs = Union(objHL.Range, rngHLs)
            End If
        Next
        
        rngHLs.Style = "Hyperlink"
                
    End Sub
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    07-01-2010
    Location
    Israel
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Excel 2010 Create a macro to check if cell contains hyperlink then apply hyperlink sty

    Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro or hyperlink for sending mail from excel 2010
    By shvraka in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-03-2013, 02:49 AM
  2. Replies: 6
    Last Post: 11-30-2012, 03:31 PM
  3. How do I create a Hyperlink in Excel from Word Macro
    By jrp_167 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-19-2010, 10:58 AM
  4. [SOLVED] How do I create a hyperlink to a cell with the hyperlink function
    By S. Bevins in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-20-2006, 03:06 PM
  5. Apply Hyperlink to Text in Cell
    By Elaine in forum Excel General
    Replies: 1
    Last Post: 01-18-2006, 02:55 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1