kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
I have this code to populate my listbox. Instead on showing me the data as i have it on my sheet, it starts from the next column. I want it to show me the data starting from column B but it started with C.
I have got get it show the data the way it is on my sheet so that i can run the other codes because most of the events rely on the first column in the list box which is now not available.
I have got get it show the data the way it is on my sheet so that i can run the other codes because most of the events rely on the first column in the list box which is now not available.
Code:
Sub Lookup()
Dim rngFind As Range
Dim strFirstFind As String
On Error GoTo errHandler:
lstWin.Clear
With Sheet1.Range("C3:C303")
Set rngFind = .Find(txtLookup.Text, LookIn:=xlValues, lookat:=xlPart)
If Not rngFind Is Nothing Then
strFirstFind = rngFind.Address
Do
If rngFind.Row > 1 Then
lstWin.AddItem rngFind.Value
lstWin.List(lstWin.ListCount - 1, 1) = rngFind.Offset(0, 1)
lstWin.List(lstWin.ListCount - 1, 2) = rngFind.Offset(0, 2)
lstWin.List(lstWin.ListCount - 1, 3) = rngFind.Offset(0, 3)
lstWin.List(lstWin.ListCount - 1, 4) = rngFind.Offset(0, 4)
lstWin.List(lstWin.ListCount - 1, 5) = rngFind.Offset(0, 5)
lstWin.List(lstWin.ListCount - 1, 6) = rngFind.Offset(0, 6)
lstWin.List(lstWin.ListCount - 1, 7) = rngFind.Offset(0, 7)
lstWin.List(lstWin.ListCount - 1, 8) = rngFind.Offset(0, 8)
lstWin.List(lstWin.ListCount - 1, 9) = rngFind.Offset(0, 9)
End If
Set rngFind = .FindNext(rngFind)
Loop While Not rngFind Is Nothing And rngFind.Address <> strFirstFind
End If
End With
Me.Reg1.Enabled = False
On Error GoTo 0
Exit Sub
errHandler::
MsgBox "Check your entry for errors"
End Sub