Hi everyone,
Just recently joined this form and just started coding for vba about 2 weeks ago or so. My issue i am having is that i would like to search a sheet range ("A2:P1100") and any cell that contains a partial match (e.g. "the" in "weather") i would like that cells entire row (in this case i have information in every cell from A:P) to be selected and pasted to "sheet2".
Once it has been pasted to another sheet I then want to specify it to populate a listbox that will dynamically change based on the number of rows i have filled in "sheet2"
The listbox is no problem, the issue i am having is that I cannot seem to find a simple way to select the entire cells row based on the cell found. Below I have posted the code i am using and works perfectly except for the fact that It only takes the value of the cell; where i want it to find that cell, select the entire row, then take the value of every cell in that row. Any help or input would be greatly appreciated.
Thank you in advance for everyone's input/help.
Private Sub CommandButton1_Click()
' activates Mastersheet where the data being searched resides and specifies the range to search in that sheet
Worksheets("Mastersheet").Select
With Range("A2:P1100")
' establishes what I am looking for (e.g. the value entered into textbox9) and returns any cells address that finds a full/parital match
Set c = .Find(what:=TextBox9.Text, LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
FirstAddress = c.Address
' takes the cells value and adds it to my listbox
Do
ListBox1.AddItem c.Value
Set c = .FindNext(c)
' loops until all cells found that contain a full/partial match
Loop While Not c Is Nothing And c.Address <> FirstAddress
End If
End With
End Sub
Display More