Search column for ComboBox Value in column and return Row text
Posted on 2013-01-21
I am pretty new to VBA and still learning the ropes as it were.
I have a userform where staff can select their names from a ComboBox and press a "Cancel Parts Request" button, which would return the last 15 data rows they entered using their Username from the ComboBox to filter on.
I would like to be able to search for the last 15 (or whatever number) of entries by a user, based on their name, which is entered in Column I and return the text in those rows.
I have been using the find function but I can't get it to recognize the name in the ComboBox. This is what I have so far:
Dim rngSearch As Range, rngFound As Range
Set rngSearch = Range("I:I")
Set rngFound = rngSearch.Find(What:="ComboBox1.Value", LookIn:=xlValues, LookAt:=xlPart)
If rngFound Is Nothing Then
MsgBox "No Parts Request Found"
I keep getting the "No Parts Request Found" message no matter what name is entered in ComboxBox1. Also I have no idea how to search for the last 15 entries from the bottom of the data and only return the data in these rows. Does anyone know the best way of achieving this?