Updating hyperlinks through a userform

Watchdawg

Board Regular
Joined
Jan 21, 2015
Messages
84
I have a userform with a command button which finds a specific cell/hyperlink which it displays in a textbox.
I want to then edit the information in the textbox (when needed) and replace the old hyperlink with the new one (or cancel if there are no changes).
Here is the code that I use to populate the text:
VBA Code:
Private Sub CommandButton1_Click()
Dim c As Range
For Each c In Worksheets("Functional Contacts").Range("A3:A100")
If c.Value = ComboBox1.Value Then
c.Select
TextBox1.Value = Selection.Hyperlinks(1).Address
End If
Next
End Sub
I need a command button that will then replace the hyperlink in the selected cell.

Thanks!!
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I have a userform with a command button which finds a specific cell/hyperlink which it displays in a textbox.
I want to then edit the information in the textbox (when needed) and replace the old hyperlink with the new one (or cancel if there are no changes).
Here is the code that I use to populate the text:
VBA Code:
Private Sub CommandButton1_Click()
Dim c As Range
For Each c In Worksheets("Functional Contacts").Range("A3:A100")
If c.Value = ComboBox1.Value Then
c.Select
TextBox1.Value = Selection.Hyperlinks(1).Address
End If
Next
End Sub
I need a command button that will then replace the hyperlink in the selected cell.

Thanks!!
I guess I should have continued searching first...I found the solution, though I don't know if it's the best solution, it does work:
VBA Code:
Private Sub CommandButton2_Click()
Dim c As Range
For Each c In Worksheets("Functional Contacts").Range("A3:A100")
If c.Value = ComboBox1.Value Then
c.Select
ActiveCell.Hyperlinks.Add Anchor:=ActiveCell, Address:=TextBox1.Value, TextToDisplay:=ComboBox1.Value

End If
Next
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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