#1   Report Post  
Greg B
 
Posts: n/a
Default listbox

I have a listbox which I am listing cells a1:a1000 on a worksheet called
"homes". I would like the ability to have the user highlight the item in
the list box and execute a code that will go to that cell.

Is this possible

Thanks

Greg


  #2   Report Post  
Tom Ogilvy
 
Posts: n/a
Default

Assuming a listbox from the control toolbox toolbar, you can use the click
event:

Private Sub ListBox1_Click()
If listbox1.ListIndex < -1 then
Range(Listbox1.Value).Select
End If
End Sub

--
Regards,
Tom Ogilvy

"Greg B" wrote in message
...
I have a listbox which I am listing cells a1:a1000 on a worksheet called
"homes". I would like the ability to have the user highlight the item in
the list box and execute a code that will go to that cell.

Is this possible

Thanks

Greg




  #3   Report Post  
Greg B
 
Posts: n/a
Default

Thanks Tom
"Tom Ogilvy" wrote in message
...
Assuming a listbox from the control toolbox toolbar, you can use the click
event:

Private Sub ListBox1_Click()
If listbox1.ListIndex < -1 then
Range(Listbox1.Value).Select
End If
End Sub

--
Regards,
Tom Ogilvy

"Greg B" wrote in message
...
I have a listbox which I am listing cells a1:a1000 on a worksheet called
"homes". I would like the ability to have the user highlight the item in
the list box and execute a code that will go to that cell.

Is this possible

Thanks

Greg






  #4   Report Post  
Greg B
 
Posts: n/a
Default

Just a little further with this one. Am I able to execute a hyperlink using
this method? I have tried it but it comes with the runtime error.

Thanks
Greg
"Greg B" wrote in message
...
Thanks Tom
"Tom Ogilvy" wrote in message
...
Assuming a listbox from the control toolbox toolbar, you can use the
click
event:

Private Sub ListBox1_Click()
If listbox1.ListIndex < -1 then
Range(Listbox1.Value).Select
End If
End Sub

--
Regards,
Tom Ogilvy

"Greg B" wrote in message
...
I have a listbox which I am listing cells a1:a1000 on a worksheet called
"homes". I would like the ability to have the user highlight the item
in
the list box and execute a code that will go to that cell.

Is this possible

Thanks

Greg








  #5   Report Post  
Tom Ogilvy
 
Posts: n/a
Default

What do you mean by execute a hyperlink. You asked about selecting a cell.

You would have to describe what you want to do if you hope to get an answer
that is relevant. Just using code to select a cell containing a hyperlink
doesn't execute the hyperlink - just like you can select a cell manually and
not fire the hyperlink.

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

might be close - it depends on what you have actually populated the Listbox
with.


--
Regards,
Tom Ogilvy

"Greg B" wrote in message
...
Just a little further with this one. Am I able to execute a hyperlink

using
this method? I have tried it but it comes with the runtime error.

Thanks
Greg
"Greg B" wrote in message
...
Thanks Tom
"Tom Ogilvy" wrote in message
...
Assuming a listbox from the control toolbox toolbar, you can use the
click
event:

Private Sub ListBox1_Click()
If listbox1.ListIndex < -1 then
Range(Listbox1.Value).Select
End If
End Sub

--
Regards,
Tom Ogilvy

"Greg B" wrote in message
...
I have a listbox which I am listing cells a1:a1000 on a worksheet

called
"homes". I would like the ability to have the user highlight the item
in
the list box and execute a code that will go to that cell.

Is this possible

Thanks

Greg










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
Formatting Listbox Hardy03 Excel Discussion (Misc queries) 0 August 4th 05 01:43 PM
Need help with Listbox Lizzie_S Excel Discussion (Misc queries) 3 July 22nd 05 04:42 AM
Help with Excel ActiveX listbox controls programmer123 Excel Discussion (Misc queries) 0 July 7th 05 11:30 PM
multiple columns / rows to be referenced through a listbox Hru48 Excel Discussion (Misc queries) 0 July 4th 05 05:12 PM
Listbox Greg Brow New Users to Excel 2 February 18th 05 10:36 AM


All times are GMT +1. The time now is 12:37 AM.

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

About Us

"It's about Microsoft Excel"