VBA to Add Hyperlinks to copied data

Viewed 25

Please I need help with my code. I am trying to add hyperlinks to the data i copy from one worksheet to another worksheet. I have researched but cannot get around adding the code to my existing code. Please I will appreciate your help.

Sub TotalPopulation()

'Dim i As Integer
 Dim lastRowdashboard As Long
 Dim i&

 i = 2

Do While i <= Worksheets.Count
     Worksheets(i).Select
     lastRow = Worksheets(i).Range("A" & Rows.Count).End(xlUp).Row
     lastRowdashboard = Worksheets("dashboard").Range("B" & Rows.Count).End(xlUp).Row

With Worksheets(i)
    For r = 2 To lastRow
        If .Range("V" & r).Value > 0 Then
            Worksheets("dashboard").Range("B" & lastRowdashboard + 1) = Worksheets(i).Name 
         ***'how do i add a code to copy the worksheet.name above with hyperlink?***
            Worksheets("dashboard").Range("C" & lastRowdashboard + 1) = .Range("D" & r)
         ***'how do i add a code to copy the .Range("D" & r) above with hyperlink?***
            Worksheets("dashboard").Range("D" & lastRowdashboard + 1) = .Range("V" & r)
            lastRowdashboard = lastRowdashboard + 1
        End If
    Next r
End With

ActiveCell.Offset(1, 0).Select
i = i + 1
Loop

Worksheets("dashboard").Select


End Sub
0 Answers
Related