Wrong Row Selected
Assuming your ListBox Column property is set to 5, and that your TextBox'es
are named TextBox1, TextBox2, etc. (the key here is that the TextBox names
have the same textual base and have sequential numbers affixed to the end of
that textual base), this code fragment will assign each of the TextBox's
Column values (for the row that was clicked on) to those TextBox'es...
Dim X As Long
......
......
For X = 1 To 5
Me.Controls("TextBox" & X).Text = Add602.Column(X - 1, Add602.ListIndex)
Next
You should be able to integrate this into your own existing code.
--
Rick (MVP - Excel)
"Sue" wrote in message
...
Hi
I have done as you suggested many thanks for that -- what is the best way
to
get info out of the List Box -- say there are 5 columns and I want to put
each row when selected into 5 separate text boxes
--
Many Thanks
Sue
"Patrick Molloy" wrote:
so
the list data starts at row 9
remember the 1st item in a listbox is undex zero as its zero based
thus
LisBox1.ListIndex = rngFound.Row - 2
in your code you define Startrownumber but don't use it...
so the line should be
LisBox1.ListIndex = rngFound.Row - Startrownumber
"Sue" wrote in message
...
Hi
I am using the code below to highlight a row in a listbox - however it
always selects a row 8 rows below which it should select. The start row
for
Column "C" is row 9 could this be the reason?? have tried all different
bits
of code all to no avail can anybody help me.
Private Sub Add602_Click()
Dim rngToSearch As Range
Dim rngFound As Range
Startrownumber = 9
Set rngToSearch = ActiveSheet.Columns("C")
Set rngFound = rngToSearch.Find(What:=Tb1B.Value, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "Sorry " & Tb1B.Value & " was not found."
Else
LisBox1.ListIndex = rngFound.Row - 2
End If
End Sub
--
Many Thanks
Sue
|