VBA If then hyperlink

srosk

Board Regular
Joined
Sep 17, 2018
Messages
132
I would like to create code.. If sheet VDR exists, then update cells D8:D11 with a hyperlink to sheet VDR. If it does not exist, put a value of N/A. Here is code for the hyperlink. I need to do this for 4 sep sheets and update 4 different ranges of cells with the hyperlink or N/A value.

Code:
[COLOR=#1f497d][FONT=Calibri][SIZE=3]ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="",SubAddress:= _[/SIZE][/FONT][/COLOR]

[COLOR=#1f497d][FONT=Calibri][SIZE=3]"'VDR'!A1", TextToDisplay:= _[/SIZE][/FONT][/COLOR]

[COLOR=#1f497d][FONT=Calibri][SIZE=3]"Review impacted participants"[/SIZE][/FONT][/COLOR]


Basically, I want it t look like this... (and work)

Code:
    If Evaluate("ISREF('VDR'!A1)") = True Then
[COLOR=#1f497d][FONT=Calibri][SIZE=3]Range("D8:D11").Value = [/SIZE][SIZE=3]ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="",SubAddress:= _[/SIZE][/FONT][/COLOR]

[COLOR=#1f497d][FONT=Calibri][SIZE=3]"'VDR'!A1", TextToDisplay:= _[/SIZE][/FONT][/COLOR]

[COLOR=#1f497d][FONT=Calibri][SIZE=3]"Review impacted participants"   [/SIZE][/FONT][/COLOR]


Else: Range("D8:D11").Value = "N/A"
              End If

I imagine I need to make a few changes to how hyperlinks create. Any help is appreciated!! Ty!!
 
Last edited:
Got it working.. thanks Joe. I appreciate your help. I am new to this, have no training and.. I guess I did not exactly know what made it 'proper syntax' or not.


As I said in post #18 , this line:
Code:
If p = 1 Then b = "D8" And c = "D8:D11" And q = "VDR" And r = "'VDR'!A1"
is NOT PROPER SYNTAX.
Try this:
Code:
If p = 1 Then 
      b = "D8"
      c = "D8:D11"
      q = "VDR"
      r = "'VDR'!A1"
End If
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,223,911
Messages
6,175,326
Members
452,635
Latest member
laura12345

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