sharky12345
Well-known Member
- Joined
- Aug 5, 2010
- Messages
- 3,422
- Office Version
- 2016
- Platform
- Windows
I'm using this to identify the row number of a Listbox selected item;
The first row is a header, hence searching for the value from row 2 onwards. In this particular test I have 2 rows of data, each having the value required so would expect to find 2 entries, (which I do), and in theory they should be identified as being on row 2 and 3 respectively.
The issue I'm having is that the very first item in the Listbox always produces a row number of 3, when in this example it should be 2 then 3.
Can anyone show me where this is going wrong please?
Code:
'All Records
If ComboBox1.Value = "All Records" Then
CmdView.Enabled = True
Total = Sheet9.Range("Q1").Value
With ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
TextBox4.Value = .List(i, 14)
Set FindRow = Sheet9.Range("O2:O500").Find(What:=TextBox4.Value, LookIn:=xlValues)
TextRow.Value = FindRow.Row
TextBox1.Value = .List(i, 0)
TextBox2.Value = Format(.List(i, 2), "dd mmmm yyyy")
TextBox3.Value = .List(i, 13)
CommandButton4.Enabled = True
End If
Next i
End With
End If
The first row is a header, hence searching for the value from row 2 onwards. In this particular test I have 2 rows of data, each having the value required so would expect to find 2 entries, (which I do), and in theory they should be identified as being on row 2 and 3 respectively.
The issue I'm having is that the very first item in the Listbox always produces a row number of 3, when in this example it should be 2 then 3.
Can anyone show me where this is going wrong please?