![]() |
Find Method; First letter
Good Day Group,
Can anyone help me with following; Trying to make a listbox filled with all items that have a selected letter, in textbox1, as its first letter. Below code seems to list all items that have the selected letter anywhere in its spelling. Thanks and Brgds CG Rosén ---------------------------------------------------------------------------- -------------- Dim s As String ListBox1.Clear With Worksheets(2).Range("B1:B231") Set j = .Find(UserForm1.TextBox1.Text, LookIn:=xlValues, SearchOrder:=xlByRows) If Not j Is Nothing Then firstAddress = j.Address Do r = j.Row s = Sheets("c").Cells(r, 2) ListBox1.AddItem s Set j = .FindNext(j) Loop While Not j Is Nothing And j.Address < firstAddress End If End With |
Find Method; First letter
With Worksheets(2).Range("B1:B231")
Set j = .Find(Left(UserForm1.TextBox1.Text,1) & "*", _ LookIn:=xlValues, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows) -- Regards, Tom Ogilvy "CG Rosén" wrote in message ... Good Day Group, Can anyone help me with following; Trying to make a listbox filled with all items that have a selected letter, in textbox1, as its first letter. Below code seems to list all items that have the selected letter anywhere in its spelling. Thanks and Brgds CG Rosén -------------------------------------------------------------------------- -- -------------- Dim s As String ListBox1.Clear With Worksheets(2).Range("B1:B231") Set j = .Find(UserForm1.TextBox1.Text, LookIn:=xlValues, SearchOrder:=xlByRows) If Not j Is Nothing Then firstAddress = j.Address Do r = j.Row s = Sheets("c").Cells(r, 2) ListBox1.AddItem s Set j = .FindNext(j) Loop While Not j Is Nothing And j.Address < firstAddress End If End With |
All times are GMT +1. The time now is 10:09 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com