Using the Find tool to find, copy and paste...

PlasticGuy

New Member
Joined
Oct 24, 2014
Messages
9
Hi there,

We are doing inventory at work and I've exported our products list out to excel. I want to find ALL the "rod" for example. That word is in the description, sometimes the first word and sometimes somewhere else in the description. All the different types of Rod are always in the same place in our warehouse though and we'd like to print off a list of all the rod. How can I use find and search for "rod" and copy the results into a different page or worksheet?

Cheers,
Jeff
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Could try something along the lines of this.
Add a new sheet named Rod.
Adjust your main sheet name and description column as necessary.

Code:
Sub RodList()

    Dim rng As Range
    Dim cel As Range
    Dim lr As Long
    Dim nextrow As Long

lr = Sheets("Your Main Sheet").Cells(Rows.Count, "K").End(xlUp).Row
With Sheets("Your Main Sheet")
    Set rng = .Range("K2:K" & lr)
    For Each cel In rng
        If InStr(1, cel.Value, "rod") > 0 Then
            nextrow = Sheets("Rod").Cells(Rows.Count, "A").End(xlUp).Row + 1
            cel.EntireRow.Copy Sheets("Rod").Cells(nextrow, 1)
        End If
    Next cel
End With
End Sub
 
Upvote 0
Upvote 0
Hi there,
So other than changing the sheet name in your code to match mine, what else needs to be changed or done?
Thank you


Could try something along the lines of this.
Add a new sheet named Rod.
Adjust your main sheet name and description column as necessary.

Code:
Sub RodList()

    Dim rng As Range
    Dim cel As Range
    Dim lr As Long
    Dim nextrow As Long

lr = Sheets("Your Main Sheet").Cells(Rows.Count, "K").End(xlUp).Row
With Sheets("Your Main Sheet")
    Set rng = .Range("K2:K" & lr)
    For Each cel In rng
        If InStr(1, cel.Value, "rod") > 0 Then
            nextrow = Sheets("Rod").Cells(Rows.Count, "A").End(xlUp).Row + 1
            cel.EntireRow.Copy Sheets("Rod").Cells(nextrow, 1)
        End If
    Next cel
End With
End Sub
 
Upvote 0
You need to specify the Sheet name that has your data and the column with the descriptions.
Put this code in your workbook by right clicking on your data sheet tab and select View Code. Paste this code into the window that comes up.
I've added enough comments to the code that you should be able to follow where and what needs to be done and what each line will do when the code runs.
Code:
Sub RodList()

    Dim rng As Range    'the range on sheet with descriptions
    Dim cel As Range    'the individual cells of that range
    Dim lr As Long      'the lastrow of the description range
    Dim nextrow As Long 'the row to copy stuff to on "Rod" sheet

Application.ScreenUpdating = False  'this speeds things up

'make sure we're working on Sheet1
With Sheets("Sheet1")       ' <= sheet name
    'get last row used in the description column
    lr = .Cells(Rows.Count, "K").End(xlUp).Row  '<= column
    'sets the range to work on => this is from row 2 to lr
    Set rng = .Range("K2:K" & lr)       '<= column
    'go down the column a cell at a time
    For Each cel In rng
        'look for "rod" any where in the cell
        If InStr(1, cel.Value, "rod") > 0 Then  'if "rod" is found
            'find the next row to copy to on the sheet named "Rod"
            nextrow = Sheets("Rod").Cells(Rows.Count, "K").End(xlUp).Row + 1  '<= column
            'copy the entire row from Sheet1 to the nextrow on Rod
            cel.EntireRow.Copy Sheets("Rod").Cells(nextrow, 1)
        End If
    'go to the next cell and do everything again
    Next cel
End With

Application.ScreenUpdating = True   'turn screen updating back on

End Sub
Close the VBA window.
Add a new sheet to your workbook, name it Rod
Save the workbook as a .xlsm (macro enabled) file

Press Alt+F8 to bring up the Macros window, select RodList and click Run.

Hope that works.
 
Upvote 0
Hi,

Please ignore my feedback above. You mentioned you're not so familiar with coding. If you use excel 2007 or higher you can use filter. Just add a filter to the worksheet and for the description column: click on filter drop down and type "rod" in search field (without quotation marks).

Then you can manually copy-paste all data on filtered sheet and paste it to another sheet.
 
Upvote 0

Forum statistics

Threads
1,221,544
Messages
6,160,428
Members
451,645
Latest member
androidmj

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top