Sunday, June 12, 2016

Conditional font coloring of hyperlinked columns

I've seen quite a few times, people requesting how to conditionally change font color of hyperlinked columns depending on the values in the cell. Let's see how to approach and address that request. I'll be using the below sample data for this exercise:
Snap 01.PNG
After applying a hyperlink on the Company Name (with the website value), let's see how can we change the font color of Apple to Aqua, Google to Green, Oracle to Orange, and so on.

Steps to add hyperlink:
  • Right click on the Company Name column -> Linking -> click Add Hyperlink
  • In the Link to Web page, in the space given to enter the web address, write the formula =[Website] and click Parse. (we already have the link value in [Website] object.
  • Choose the Target window as New window
  • In Tooltip, click the down arrow on the right, click build formula, write formula as ="http://"+[Website], and click OK
  • Click Apply and OK
Snap 03.pngSnap 02.png
Steps to format hyperlink:
  • Click inside the cell of one of the Company Names to see the html code in the Formula bar, which would be ="<a href=\"=[Website]\" title=\""+("http://"+[Website])+"\" target=\"_blank\" nav=\"web\">"+[Company Name]+"</a>" as shown below.
Snap 04.png

  • Between "a" and "href" in the "a href" in the beginning , add the text style='text-decoration:none;" +  (If([Company Name]="Apple") Then "color:aqua" ElseIf([Company Name]="Facebook") Then "color:#4766A9"  ElseIf([Company Name]="Google") Then "color:green" ElseIf([Company Name]="Oracle") Then "color:red" ElseIf([Company Name]="SAP") Then "color:orange") + "' and parse and apply the formula.

Note: The whole text in the cell would now be:
="<a  style='text-decoration:none;" +  (If([Company Name]="Apple") Then "color:aqua" ElseIf([Company Name]="Facebook") Then "color:#4766A9"  ElseIf([Company Name]="Google") Then "color:green" ElseIf([Company Name]="Oracle") Then "color:red" ElseIf([Company Name]="SAP") Then "color:orange") + "' href=\"=[Website]\" title=\""+("http://"+[Website])+"\" target=\"_blank\" nav=\"web\">"+[Company Name]+"</a>"

This is what the result looks like, Facebook is showing up before Apple, because of the color code we're using for Facebook will come before color name we're using for Apple, when sorted. We can add Company Name in the beginning, so it sorts using Company Name and then hide that extra column by right clicking on it -> Hide -> click on Hide Dimension.
Snap 05.png



Source:
https://blogs.sap.com/2016/06/07/conditional-font-coloring-of-hyperlinked-columns/

1 comment:

  1. I'm Абрам Александр a businessman who was able to revive his dying lumbering business through the help of a God sent lender known as Benjamin Lee the Loan Consultant. Am resident at Yekaterinburg Екатеринбург. Well are you trying to start a business, settle your debt, expand your existing one, need money to purchase supplies. Have you been having problem trying to secure a Good Credit Facility, I want you to know that Mr Benjamin will see you through. Is the right place for you to resolve all your financial problem because am a living testimony and i can't just keep this to myself when others are looking for a way to be financially lifted.. I want you all to contact this God sent lender using the details as stated in other to be a partaker of this great opportunity Email: 247officedept@gmail.com  Or  WhatsApp/Text +1-989-394-3740.

    ReplyDelete