Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Finding Cell Address from Listbox

Hello,

I need some help in finding a specific cell address for a selection from
a ListBox. For example, if the ListBox.RowSource = D15:D25, and the third
item in the list was selected (ListIndex = 2) the cell address D17 is
returned. I have fumbled around with relative positioning and have
accomplished nothing but confusion.

Any help or direction to look would be greatly appreciated.

Thanks,
Ken


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Finding Cell Address from Listbox

Ken,

ListIndex starts its numbering at zero, so the third item selected
has a ListIndex of 2.
Also, if you set the ListIndex to -1 then nothing will be displayed.
The last item in a ListBox has a ListIndex equal to the ListCount -1.

Generally speaking, Collections (like "Worksheets") start their numbering with 1.
Arrays (like the "List" property) start their numbering with 0.

The help file does cover most of this.
For what its worth, the XL97 help file is much easier to use than those provided with later versions.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Eubanks"
wrote in message
Hello,
I need some help in finding a specific cell address for a selection from
a ListBox. For example, if the ListBox.RowSource = D15:D25, and the third
item in the list was selected (ListIndex = 2) the cell address D17 is
returned. I have fumbled around with relative positioning and have
accomplished nothing but confusion.
Any help or direction to look would be greatly appreciated.
Thanks,
Ken


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Finding Cell Address from Listbox

This seems to work for me:

Private Sub ListBox1_Change()
Dim rng As Range
Dim LstAdr As String
Set rng = Range(ListBox1.ListFillRange)
LstAdr = Cells(WorksheetFunction.Index(rng, ListBox1.ListIndex + 1).Row, _
Range(ListBox1.ListFillRange).Column).Address
Range("A1").Value = LstAdr
End Sub


Mike F
"Eubanks" wrote in message
...
Hello,

I need some help in finding a specific cell address for a selection
from a ListBox. For example, if the ListBox.RowSource = D15:D25, and the
third item in the list was selected (ListIndex = 2) the cell address D17
is returned. I have fumbled around with relative positioning and have
accomplished nothing but confusion.

Any help or direction to look would be greatly appreciated.

Thanks,
Ken




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Finding Cell Address from Listbox

Mike,

Most Excellent!!! Thanks! I decided to use a ComboBox instead of a
ListBox so I had to modify the code slightly to work with its properties
(RowSource vs ListFillRange).

Thanks again for getting me off high center.
Ken

"Mike Fogleman" wrote in message
m...
This seems to work for me:

Private Sub ListBox1_Change()
Dim rng As Range
Dim LstAdr As String
Set rng = Range(ListBox1.ListFillRange)
LstAdr = Cells(WorksheetFunction.Index(rng, ListBox1.ListIndex + 1).Row, _
Range(ListBox1.ListFillRange).Column).Address
Range("A1").Value = LstAdr
End Sub


Mike F
"Eubanks" wrote in message
...
Hello,

I need some help in finding a specific cell address for a selection
from a ListBox. For example, if the ListBox.RowSource = D15:D25, and
the third item in the list was selected (ListIndex = 2) the cell address
D17 is returned. I have fumbled around with relative positioning and
have accomplished nothing but confusion.

Any help or direction to look would be greatly appreciated.

Thanks,
Ken






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Finding Cell Address from Listbox

Glad it worked. Thanks for the feedback!
Mike F
"Eubanks" wrote in message
...
Mike,

Most Excellent!!! Thanks! I decided to use a ComboBox instead of a
ListBox so I had to modify the code slightly to work with its properties
(RowSource vs ListFillRange).

Thanks again for getting me off high center.
Ken

"Mike Fogleman" wrote in message
m...
This seems to work for me:

Private Sub ListBox1_Change()
Dim rng As Range
Dim LstAdr As String
Set rng = Range(ListBox1.ListFillRange)
LstAdr = Cells(WorksheetFunction.Index(rng, ListBox1.ListIndex + 1).Row,
_
Range(ListBox1.ListFillRange).Column).Address
Range("A1").Value = LstAdr
End Sub


Mike F
"Eubanks" wrote in message
...
Hello,

I need some help in finding a specific cell address for a selection
from a ListBox. For example, if the ListBox.RowSource = D15:D25, and
the third item in the list was selected (ListIndex = 2) the cell address
D17 is returned. I have fumbled around with relative positioning and
have accomplished nothing but confusion.

Any help or direction to look would be greatly appreciated.

Thanks,
Ken








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
Finding Cell address by value default105 Excel Discussion (Misc queries) 2 June 30th 09 09:31 PM
Finding Cell address by value default105 Excel Discussion (Misc queries) 1 June 30th 09 11:05 AM
Finding the Address of a Cell tb Excel Worksheet Functions 5 December 13th 07 01:59 PM
finding the address of a specific cell? botha822[_5_] Excel Programming 4 August 9th 06 11:26 PM
Finding cell address... korcutt Excel Programming 2 November 7th 05 10:50 PM


All times are GMT +1. The time now is 06:56 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"