GomaPile
Active Member
- Joined
- Jul 24, 2006
- Messages
- 334
- Office Version
- 365
- Platform
- Windows
Hello to All and happy Independencia (4th) Day to everyone,
Im bored!! Having a play using Listbox's & Textbox's - anyways found this vba code while browsing on YouTube but it won't work. Sadly, there was no support in the comments section neither.
Im in no rush guys.... did checked & double checked the code over and over. No idea why it stopped at this point - Me.ListBox1.List(0, lst - 1) = Sheet2.Cells(1, lst)
And Im guessing there more errors after that one... who knows lol lol
Cheers
GomaPile (Nasa2)
Im bored!! Having a play using Listbox's & Textbox's - anyways found this vba code while browsing on YouTube but it won't work. Sadly, there was no support in the comments section neither.
Im in no rush guys.... did checked & double checked the code over and over. No idea why it stopped at this point - Me.ListBox1.List(0, lst - 1) = Sheet2.Cells(1, lst)
And Im guessing there more errors after that one... who knows lol lol
VBA Code:
Private Sub TextBox1_Change()
Dim rng As Range
Dim r As Long
Dim cln, lst As Integer
Me.ListBox1.Clear
Set rng = Sheet2.Range("A4").CurrentRegion
Me.ListBox1.AddItem
For lst = 1 To rng.Columns.Count
Me.ListBox1.List(0, lst - 1) = Sheet2.Cells(1, lst) [COLOR=rgb(65, 168, 95)]' <------------- Error stops here[/COLOR]
Next lst
Me.ListBox1.Selected(0) = True
For r = 2 To rng.Rows.Count
If InStr(UCase(Sheet2.Cells(r, "A")) & Sheet2.Cells(r, "B"), UCase(Me.TextBox1)) > 0 _
And Me.TextBox1 <> "" Then
Me.ListBox1.AddItem
For cln = 1 To rng.Columns.Count
Me.ListBox1.List(ListBox1.ListCount - 1, cln - 1) = Sheet2.Cells(r, cln)
Next cln
End If
Next r
End Sub
Cheers
GomaPile (Nasa2)