Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default hyperlink in listbox

I have this macro which searching for 3 words in same row and if it find
some then display them in listbox. some rows contain hyperlink and i would
like to keep this function. please help.
some er hyperlinks on internet and some on my c:drive.

Private Sub CommandButton1_Click()

Dim sOne, sOneItem

With UserForm1
'******
If .OptionButton1 Then sOne = Array("Horse")
If .OptionButton2 Then sOne = Array("Pig")
If .OptionButton5 Then sOne = Array("Horse", "Pig")
'******
If .OptionButton3 Then
sTwo = "Dansk"
Else
sTwo = "Engelsk"
End If
sThree = .TextBox1.Text
End With

'******
For Each sOneItem In sOne
'******
'MsgBox sOneItem
With Worksheets(1).Cells
Set c = .Find(sOneItem, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
If Application.CountIf(c.EntireRow, "*" & sTwo & "*") And _
Application.CountIf(c.EntireRow, "*" & sThree & "*")
Then
UserForm1.ListBox1.AddItem
UserForm1.ListBox1.List( _
UserForm1.ListBox1.ListCount - 1, 0) _
= c.Offset(0, -6).Value
UserForm1.ListBox1.List( _
UserForm1.ListBox1.ListCount - 1, 1) _
= c.Offset(0, -3).Value
End If
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
'******
Next
'******
End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default hyperlink in listbox

I don't think you're gonna get a hyperlink to work in your listbox.

Maybe you can keep track of which entries in the listbox list contain
hyperlinks. Then if one of those is selected, you can use:

Thisworkbook.followhyperlinks xxxx

to mimic that behavior.

Alen32 wrote:

I have this macro which searching for 3 words in same row and if it find
some then display them in listbox. some rows contain hyperlink and i would
like to keep this function. please help.
some er hyperlinks on internet and some on my c:drive.

Private Sub CommandButton1_Click()

Dim sOne, sOneItem

With UserForm1
'******
If .OptionButton1 Then sOne = Array("Horse")
If .OptionButton2 Then sOne = Array("Pig")
If .OptionButton5 Then sOne = Array("Horse", "Pig")
'******
If .OptionButton3 Then
sTwo = "Dansk"
Else
sTwo = "Engelsk"
End If
sThree = .TextBox1.Text
End With

'******
For Each sOneItem In sOne
'******
'MsgBox sOneItem
With Worksheets(1).Cells
Set c = .Find(sOneItem, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
If Application.CountIf(c.EntireRow, "*" & sTwo & "*") And _
Application.CountIf(c.EntireRow, "*" & sThree & "*")
Then
UserForm1.ListBox1.AddItem
UserForm1.ListBox1.List( _
UserForm1.ListBox1.ListCount - 1, 0) _
= c.Offset(0, -6).Value
UserForm1.ListBox1.List( _
UserForm1.ListBox1.ListCount - 1, 1) _
= c.Offset(0, -3).Value
End If
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
'******
Next
'******
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default hyperlink in listbox

where to insert your sugestion Thisworkbook.followhyperlinks xxxx


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default hyperlink in listbox

Maybe in the listbox_change procedure?

Or if you have a button that says "ok", put it in there.



Alen32 wrote:

where to insert your sugestion Thisworkbook.followhyperlinks xxxx


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default hyperlink in listbox

And the xxxx would be the link that you kept track of -- it's not really xxxx.

Alen32 wrote:

where to insert your sugestion Thisworkbook.followhyperlinks xxxx


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default hyperlink in listbox

I did try but doesn't work

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default hyperlink in listbox

Maybe this will get you further along.

I put a listbox and two commandbuttons on a userform.

This is the code I used under the userform:

Option Explicit
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()
Dim myURL As String

If Me.ListBox1.ListIndex -1 Then
'something's selected
myURL = Me.ListBox1.List(Me.ListBox1.ListIndex, 1)
End If

If myURL = "" Then
'do nothing
Else
ThisWorkbook.FollowHyperlink Address:=myURL
End If

End Sub

Private Sub UserForm_Initialize()
Dim myCell As Range
Dim myRng As Range

With Me.ListBox1
.ColumnCount = 2
.ColumnWidths = "20;0"
.RowSource = ""
.Clear

With Worksheets("sheet1")
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
End With

For Each myCell In myRng.Cells
.AddItem myCell.Value
If myCell.Hyperlinks.Count 0 Then
.List(.ListCount - 1, 1) = myCell.Hyperlinks(1).Address
Else
.List(.ListCount - 1, 1) = ""
End If
Next myCell

End With

Unload Me

End Sub


Alen32 wrote:

I did try but doesn't work


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlink in multicolumn listbox Alen32 Excel Programming 1 March 5th 05 03:36 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM
How to create a ListBox with 'hyperlink'-like items in VBA ? Jürgen Germonpré Excel Programming 2 July 25th 03 09:25 AM
How to create a ListBox with 'hyperlink'-like items in VBA ? Phillip R Excel Programming 0 July 24th 03 10:32 PM


All times are GMT +1. The time now is 02:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"