ListBox Question
Just because you rename the form, the event is still for Userform(sic!).
Private Sub UserForm_Initialize()
Dim cell As Range
Me.ListBox1.ColumnCount = 2
Me.ListBox1.BoundColumn = 1
Me.ListBox1.ColumnWidths = "0;1"
For Each cell In Sheet1.Range("AC2:AC69").Cells
Me.ListBox1.AddItem cell.Hyperlinks(1).SubAddress
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) =
cell.Hyperlinks(1).TextToDisplay
Next cell
End Sub
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"RK" wrote in message
...
Can this be done?
I am trying to use a form with a listbox. So far I have
been unable to get the hyperlinks listed, only the
friendly name. I would like to list the friendly name,
but be able to click the friendly name and active the
hyperlink. (The reason, the hyperlink doesn't make any
sense to the normal user) The code I currently using is:
(I need to do other things to this as well, but I can't
go forward without resolving this.)
Has anyone done this?
Private Sub CommandButton2_Click()
Dim i As Long
For i = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(i) Then
Range(Me.ListBox1.List(i)).Parent.PrintOut
End If
Next i
End Sub
Private Sub frmUserForm1_Initialize()
Dim cell As Range
Me.ListBox1.ColumnCount = 2
Me.ListBox1.BoundColumn = 1
Me.ListBox1.ColumnWidths = "0;1"
For Each cell In Sheet1.Range("AC2:AC69").Cells
Me.ListBox1.AddItem cell.Hyperlinks(1).SubAddress
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) =
cell.Hyperlinks.TextToDisplay
Next cell
End Sub
|