davedave24
Programmer
I'm attempting to search Row 1 of a sheet for a string in a combobox.
This works fine with my code for searching down a column for a string, but searching the row it only works up to Row Z. From Cols AA-AZ it loads column A, and BA-BZ it loads column B.
Once it has found the name, move down 2 cells, and load that column into an array (which I'm putting in a listbox for this example only).
This works fine with my code for searching down a column for a string, but searching the row it only works up to Row Z. From Cols AA-AZ it loads column A, and BA-BZ it loads column B.
Once it has found the name, move down 2 cells, and load that column into an array (which I'm putting in a listbox for this example only).
Code:
Dim rngFind As Range
With Sheets("ProductList").Range("1:1")
Set rngFind = .Find(comboCustomer, , xlValues, MatchCase:=False)
End With
If Not rngFind Is Nothing Then 'found customer name
Application.Goto rngFind, True
ActiveCell.Offset(2, 0).Select 'move down to first data
'start cell
Dim rngA As String
rngA = ActiveCell.Address(False, False)
'startcell column letter
Dim rngB As String
rngB = Mid(rngA, 1, 1)
'load the customers into an array
Dim rngP As Range
With Sheets("ProductList")
Set rngP = .Range(.Range(rngA), .Cells(Rows.Count, rngB).End(xlUp))
End With
'add the customer array to the combobox
ListBox1.RowSource = rngP.Address(External:=True)
End If