#1   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 54
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  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default listbox

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  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default listbox

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  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default listbox

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  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default listbox

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
listbox B conditional of input in Listbox A Kim K Excel Discussion (Misc queries) 1 October 31st 06 08:27 PM
VBA: Creating listbox similar to the one in Pivot table (Listbox+Checkbox) modjoe23 Excel Programming 3 August 18th 05 02:35 PM
Modification of listbox to listbox code Sam S via OfficeKB.com Excel Programming 0 July 28th 05 12:02 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


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

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"