Diving_Dan
Board Regular
- Joined
- Oct 20, 2019
- Messages
- 161
Evening all,
I'm having problems with the following code. It all works except for the line to add the hyperlink. I have a textbox on a userform called textWebsite where I input a website URL. I need to input that URL into K4 on the relevant worksheet, "ws" and display the text "Link to Website".
The rest of the code works fine and does what I need but nothing happens with this line of code.
Any help will be greatly appreciated as always.
Dan
I'm having problems with the following code. It all works except for the line to add the hyperlink. I have a textbox on a userform called textWebsite where I input a website URL. I need to input that URL into K4 on the relevant worksheet, "ws" and display the text "Link to Website".
The rest of the code works fine and does what I need but nothing happens with this line of code.
Any help will be greatly appreciated as always.
Dan
VBA Code:
Private Sub cmdCreate_Click()
Dim ws As Worksheet
Set ws = Sheets("Debt Template")
ws.Range("A1") = textDebtFor
ws.Range("I1") = textOriginalDebt
ws.Range("I2") = textDebtNowWith
ws.Range("I3") = textCurrentReference
ws.Range("I4") = textOriginalReference
ws.Hyperlinks.Add Range("K4"), Address:=textWebsite, TextToDisplay:="Link to Website"
Dim iRow As Long
Dim ws2 As Worksheet
Dim z As Control
Set ws2 = Sheets("List of Debts")
ws2.ListObjects("Table15").ShowTotals = False
iRow = ws2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ws2.Cells(iRow, 1).Value = textDebtFor
ws2.Cells(iRow, 2).Value = textOriginalDebt
ws2.Cells(iRow, 5).Value = textOriginalReference
Sheets("Debt Template").Copy After:=Sheets("Debts")
ActiveSheet.Name = ActiveSheet.Range("I1").Value
ws2.Cells(iRow, 3).Value = "='" & textOriginalDebt & "'!I2"
ws2.Cells(iRow, 4).Value = "='" & textOriginalDebt & "'!I3"
ws2.Cells(iRow, 6).Value = "='" & textOriginalDebt & "'!I5"
ws2.Cells(iRow, 7).Value = "='" & textOriginalDebt & "'!L1"
ws2.ListObjects("Table15").ShowTotals = True
Unload Me
Sheets("Debts").Select
End Sub