Hi,
I'm attempting modify some code from one userform to a new one, using different cell references from the original macro. I'm working at a level where I am beginning to understand VBA functions but I admit that this code is just a little bit beyond my understanding (it was previously given to me in this forum to help with the first listbox I put together).
I've changed the code as best I can and am getting a "424 Object Required" error, where the ## is in the code below.
I'm happy to give more detail as to the thing i'm trying to do but briefly, the user will change a combobox called CB_Name, then the code runs which will look for all the times that name is mentioned in COL P (of another sheet, not the activesheet), then list all of the Items in col B rows that contain that name. The current code below does this by using the "find" feature that excel has and using an offset of -14 columns after the initial "find all of that name" part - I think i've changed the cell references correctly but i can't think of why a previously working code has this error now.
LB_Items.Clear
Set rngLook = Range("p3:p" & Range("p40000").End(xlUp).Row)
strValueToPick = CB_Name.Value
With rngLook
Set rngFind = .Find(strValueToPick, .Cells(1, 1), LookIn:=xlValues, lookat:=xlWhole)
If Not rngFind Is Nothing Then
strFirstAddress = rngFind.Address
Set rngPicked = rngFind
Do
Set rngPicked = Union(rngPicked, rngFind)
Set rngFind = .FindNext(rngFind)
Loop While Not rngFind Is Nothing And rngFind.Address <> strFirstAddress
End If
End With
## If Not rngPicked Is Nothing Then
rngPicked.Offset(0, -14).Select
'Fill Listbox
For Each c In Selection
LB_Items.AddItem c.Value
Next
End If
Bookmarks