M
Minitman
Greetings,
I have a UserForm with a ComboBox(CB1) and 15 TextBoxes(TB1 thru TB15)
on it. The RowSource for CB1 is a 12column wide named range. I tried
to add a search button to find any match in column A instead of just
the first letters typed into CB1 (I forgot about the 12 column
width!).
Here is the code for the search button:
*****************************************************************************
Private Sub SearchButton1_Click()
Dim lCount As Long
Dim rFoundCell As Range
Dim lLoop As Long
Dim wSheet As Worksheet
Dim StrFind As String
Set wSheet = Worksheets("Food_List")
Set rFoundCell = wSheet.Range("A1")
StrFind = CB1.Value
lLoop = WorksheetFunction.CountIf(wSheet.Columns(1), "*" & _
StrFind & "*")
If lLoop > 0 Then
CB1.RowSource = vbNullString
CB1.Value = vbNullString
End If
For lCount = 1 To lLoop
Set rFoundCell = wSheet.Columns(1).Find(What:=StrFind, _
After:=rFoundCell, LookIn:=xlValues, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)
CB1.AddItem rFoundCell
Next lCount
End Sub
*****************************************************************************
My Question is, how do I make rFoundCell 12 columns wide?
Any help or is appreciated.
TIA
-Minitman
I have a UserForm with a ComboBox(CB1) and 15 TextBoxes(TB1 thru TB15)
on it. The RowSource for CB1 is a 12column wide named range. I tried
to add a search button to find any match in column A instead of just
the first letters typed into CB1 (I forgot about the 12 column
width!).
Here is the code for the search button:
*****************************************************************************
Private Sub SearchButton1_Click()
Dim lCount As Long
Dim rFoundCell As Range
Dim lLoop As Long
Dim wSheet As Worksheet
Dim StrFind As String
Set wSheet = Worksheets("Food_List")
Set rFoundCell = wSheet.Range("A1")
StrFind = CB1.Value
lLoop = WorksheetFunction.CountIf(wSheet.Columns(1), "*" & _
StrFind & "*")
If lLoop > 0 Then
CB1.RowSource = vbNullString
CB1.Value = vbNullString
End If
For lCount = 1 To lLoop
Set rFoundCell = wSheet.Columns(1).Find(What:=StrFind, _
After:=rFoundCell, LookIn:=xlValues, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)
CB1.AddItem rFoundCell
Next lCount
End Sub
*****************************************************************************
My Question is, how do I make rFoundCell 12 columns wide?
Any help or is appreciated.
TIA
-Minitman