+ Reply to Thread
Results 1 to 6 of 6

Conditional Formatting - if there is hyperlink

  1. #1
    Registered User
    Join Date
    08-31-2006
    Posts
    11

    Conditional Formatting - if there is hyperlink

    Hi again everyone,

    I've posted this similar question, but it's not on hyperlink.

    Anyway, i want to check in a given cell, if I put a hyperlink, i want it to be GREEN in colour, and if i remove the hyperlink, it returns to YELLOW.

    Can I do this with UDF, via VBA?

    cheers

  2. #2
    Valued Forum Contributor Excelenator's Avatar
    Join Date
    07-25-2006
    Location
    Wantagh, NY
    Posts
    333
    this code will check each cell with a constant in it and if it is a hyperlink turn the interior color of the cell to green, if it is NOT then it turns the interior color to yellow.


    Please Login or Register  to view this content.
    ---------------------------------------------------
    ONLY APPLIES TO VBA RESPONSES WHERE APPROPRIATE
    To insert code into the VBE (Visual Basic Editor)
    1. Copy the code.
    2. Open workbook to paste code into.
    3. Right click any worksheet tab, select View Code
    4. VBE (Visual Basic Editor) opens to that sheets object
    5. You may change to another sheets object or the This Workbook object by double clicking it in the Project window
    6. In the blank space below the word "General" paste the copied code.

  3. #3
    Registered User
    Join Date
    01-22-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Conditional Formatting - if there is hyperlink

    That code works well - thank you. What would you change if you wanted only the cells containing hyperlinks to change colour while all other cells remained the same?

  4. #4
    Registered User
    Join Date
    04-20-2015
    Location
    Melbourne,Australia
    MS-Off Ver
    2013
    Posts
    1

    Re: Conditional Formatting - if there is hyperlink

    In Conditional Formatting you can use the Method "IsFormula" to check if a formula is in a cell. Set your formatting as appropriate using that.

    In the field you want the Hyperlink, use the "HYPERLINK(link_location, [friendly_name])" formula method instead of the "right mouse click > add Hyperlink" method.

    My links all look like this as formulas:
    =HYPERLINK("C:\MyFilePath\MyFileName.xlsx", "MyDisplayedLink")

  5. #5
    Registered User
    Join Date
    03-10-2014
    Location
    Egypt
    MS-Off Ver
    Excel 2013
    Posts
    4

    Re: Conditional Formatting - if there is hyperlink

    Hello,
    This code works very well, but I need to make it for range from B2:B1000 only, any help?

    also after each update it selects all the cells, any help on how to disable the selection?

  6. #6
    Registered User
    Join Date
    03-10-2014
    Location
    Egypt
    MS-Off Ver
    Excel 2013
    Posts
    4

    Re: Conditional Formatting - if there is hyperlink

    Quote Originally Posted by Moh.zizo View Post
    Hello,
    This code works very well, but I need to make it for range from B2:B1000 only, any help?

    also after each update it selects all the cells, any help on how to disable the selection?
    I found the solution if anyone is interested.

    Formula: copy to clipboard
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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