Check active cell - if 'hyperlink' exist enable command button

Stripez3

New Member
Joined
Feb 8, 2014
Messages
6
I have worksheet("DATA") and in Column 'C' I have a long list of about 50 names. Some of the names have 'hyperlinks' that are linked to a web page and half of those names don't have a 'hyperlink'. I have a 'Userform'(DATA) with a current command button (see below example 1 that works) and I would like to change this command button so that I can set it to (enabled = false) and then when you go to an active cell in Column 'C' that has a 'hyperlink' the command button is (enabled=true) and when your in an active cell in Column 'C' that does not have a 'hyperlink' the command button is back to not (enabled=false).

This is where I need help. How do i combine these two examples to work? Below in example 2(not working) are some bits of code that I tried to get to work. I cannot figure out how to combined these two codes so the command button to checks the active cell in Column 'C' for the name that has a 'hyperlink' and then enables the button... HELP!


EXAMPLE 1
Private Sub cmboweb_Click()
Sheets("DATA").Select
If Selection.Hyperlinks.Count > 0 Then
Selection.Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
End If
End Sub

---------------------------------------

EXAMPLE 2
Private Sub cmboweb_Click()
If Selection.Hyperlinks.Count > 0 Then
cmboweb.Enabled = True
Else
cmboweb.Enabled = False
End If
End Sub


...or just a thought, would there be better to put code under the Userform_Activate to see if there is 'hyperlinks' in the Column 'C' and enable the command button?

I put this code under the Userform_Activate and it enables the command button but does not take it back to (false)?

If Selection.Hyperlinks.Count > 0 Then
Selection.Select
cmboweb.Enabled = True
Else
cmboweb.Enabled = False
End If
 

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