PDA

View Full Version : Dynamic Hyperlink VBA



user124
03-27-2020, 09:05 AM
Hi all,

I have a question regarding making a hyperlink dynamic. Below I have posted my code that I have so far. I want to make the hyperlink in a way where the sub address directs me to cell "ws.Range("E" & count).value". The cell keeps changing as it keeps looping and hence I want to do the same with my hyperlink. Thanks in advance!

Public Sub tatrigger(ws As Worksheet)

Dim i As Long
Dim x As Long
Dim lastRow As Long
Dim first As Long
Dim last As Long
Dim count As Long

Application.ScreenUpdating = False

lastRow = ws.Cells(Rows.count, "C").End(xlUp).Offset(2, 0).row
first = ws.Range("Trigger_Table").row
last = ws.Cells(Rows.count, "C").End(xlUp).Offset(-1, 0).row

'looks for tip and copies task name, task descrption, umbrella into bulk add (regardless of duplicates)

For count = first To last
If ws.Range("C" & count).value = "ta" Then
ws.Range("E" & count).Copy
For i = lastRow To lastRow
ws.Range("C" & i + x).PasteSpecial Paste:=xlPasteValues
'ActiveCell.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:=ws.Range("E" & count)
ws.Range("C" & count).value = "ta- added to takeaways"
Next i
x = x + 1
End If
Next count

Application.CutCopyMode = False
Application.ScreenUpdating = True End Sub

rlv
03-28-2020, 04:25 PM
Cross posted here:
https://www.mrexcel.com/board/threads/dynamic-hyperlink-vba.1128856/