Conditional formatting criterion

harry888

New Member
Joined
Aug 1, 2017
Messages
5
I have a macro that creates a hyperlink anchored to some text, using a variable named "URL", like this.
Code:
URL = "[URL]http://www.mydomain.com/mypage?parameter[/URL]=" & [A1]
ActiveSheet.Hyperlinks.Add Anchor:=[C3], _
    Address:=URL, TextToDisplay:="MyText"
I want to use conditional formatting to highlight a cell if URL has a particular value; e.g., if URL = "http://www.mydomain.com/mypage?parameter=" (i.e., [A1] = null.)
I tried using this ...
Code:
=URL="[URL]http://www.mydomain.com/mypage?parameter="[/CODE[/URL]]
... as the conditional formatting formula, but it didn't work. How do I make this work?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi Harry
Welcome to the board

I don't know any excel native worksheet function that gives you the hyperlink address.
You'll have to write a udf to extract the hyperlink in the cell and use it in the conditional formatting formula.
 
Upvote 0
Thanks for your reply. I don't know how to write a udf (user-defined function?), but is it necessary to extract the hyperlink given that it is already set in the variable "URL"? Is it not possible just to use the variable in the conditional formatting formula?
 
Upvote 0
Thanks for your reply. I don't know how to write a udf (user-defined function?), but is it necessary to extract the hyperlink given that it is already set in the variable "URL"? Is it not possible just to use the variable in the conditional formatting formula?

Hi

Sorry, unless you have defined some name yourself I see no variable, I just see 3 letters, URL.

If you want to use a UDF, this is an example.

Paste in a standard module:

Code:
Function GetUrl(r As Range) As String
If r.Count = 1 Then If r.Hyperlinks.Count > 0 Then GetUrl = r.Hyperlinks(1).Address
End Function

Then, for ex. select C1:C10 and in the conditional formatting use the formula:

=GetUrl(C1)="http://www.mydomain.com/mypage?parameter="&$A$1

and set the highlighting format.

With the code you posted in post #1 , C3 should be highlighted
 
Upvote 0

Forum statistics

Threads
1,224,829
Messages
6,181,219
Members
453,024
Latest member
Wingit77

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