Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default ListBox index question ...

To All,

I have a ListBox on a UserForm that works fine ... what I'm trying to
do now is use the .ListIndex in conjunction with offset ... so that I
can assign the adjacent cells contents to a Label's caption:
LblDescription.Caption

I'm stuck trying to convert this index number to an address - with the
hope to then use that address and "offset" 1 cell right ...

Could someone guide me on the correct procedure ...

Thanks,

JimP

''''''''''''''''''''''''''''''''''''''''''

Private Sub ListBox1_Click()
Dim sIndexName As String: sIndexName = ""
' ITEM
With Me.ListBox1
If .ListIndex -1 Then
sIndexName = .List(.ListIndex)
End If
End With
' followingline is a problem ...
' LblDescription.Caption = ActiveSheet.Range(sIndexName).Address. _
' Offset(0, 1).Value

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default ListBox index question ...

Jim,

I'm not sure I understand what you are trying to do, but this might help.
I'm assuming a UserForm1, ListBox1 and CommandButton1. On Sheet1, cells
A1:A4 are a range named "r_source." I filled it with "a", "b", "c" and "d".
When you run the form and click on the button, it puts the value in the
listbox in the cell in column B.

Private Sub UserForm_Initialize()
With Me.ListBox1
.RowSource = Worksheets("Sheet1").Range("r_source").Address
.ListIndex = 0
End With
End Sub

Private Sub CommandButton1_Click()
With Me.ListBox1
Range("r_source").Cells(.ListIndex + 1, 2) = .Value
End With

End Sub

hth,

Doug Glancy

"JimP" wrote in message
om...
To All,

I have a ListBox on a UserForm that works fine ... what I'm trying to
do now is use the .ListIndex in conjunction with offset ... so that I
can assign the adjacent cells contents to a Label's caption:
LblDescription.Caption

I'm stuck trying to convert this index number to an address - with the
hope to then use that address and "offset" 1 cell right ...

Could someone guide me on the correct procedure ...

Thanks,

JimP

''''''''''''''''''''''''''''''''''''''''''

Private Sub ListBox1_Click()
Dim sIndexName As String: sIndexName = ""
' ITEM
With Me.ListBox1
If .ListIndex -1 Then
sIndexName = .List(.ListIndex)
End If
End With
' followingline is a problem ...
' LblDescription.Caption = ActiveSheet.Range(sIndexName).Address. _
' Offset(0, 1).Value

End Sub



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
Problem using INDEX to select items in listbox Shazbot Excel Discussion (Misc queries) 3 April 28th 06 09:06 AM
Listbox Question Greg B Excel Discussion (Misc queries) 1 March 9th 05 02:17 PM
listbox question GMet Excel Programming 1 September 27th 04 07:59 PM
Listbox Index Problem Todd Huttenstine Excel Programming 3 April 26th 04 05:22 PM
Filling a listbox depending on font index Trevor[_3_] Excel Programming 0 October 1st 03 08:25 PM


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