Please Help

  • Thread starter Thread starter Greg B
  • Start date Start date
G

Greg B

I got help from some one last night and they gave me this code

Private Sub ListBox1_Click()
Dim rng as Range
If listbox1.ListIndex <> -1 then
set rng = Range(Listbox1.Value)
if rng.hyperlinks.count > 0 then
rng.select
rng.parent.parent.FollowHyperlink rng.hyperlinks(1).Address, _
rng.Hyperlinks(1).SubAddress, True
end if
End If
End Sub

The trouble I am having it is coming up with the error,

Run-time error '1004':
Method 'range' of object_global failed

I was asked how I populated the listbox and this is how I did it

Private Sub UserForm_Activate()
ListBox1.RowSource = "a:e"
End Sub

Where am I going wrong?

Thanks
Greg
 
I have worked it out all I did was the following code. I think I was
thinking too complicated for what i needed.

Private Sub ListBox1_Click()

ActiveSheet.Range("A1").Offset(ListBox1.ListIndex).Select

Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True


End Sub
Thanks
Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Creating a List using a Form 5
VB and Advanced Filter 2
list box 2
move item in multiselect listbox 1
UserForm past data 7
Print a selected number of sheets 9
#REF! help please 3
UserForm ListBox 1

Back
Top