Make Find, Copy, Paste Macro Find More than One Search Term

JamesA11

New Member
Joined
Oct 2, 2020
Messages
17
Office Version
  1. 2019
Platform
  1. Windows
Hello

I am using this macro to find, copy and paste rows where column E contains 0.1. I would like to adapt it so it also finds, copies, pastes rows where column E contains 0.11, 0.12, 0.13.

How do I amend it to make it work?

Thanks

VBA Code:
Option Explicit

Sub ParseData()

Dim Cell As Range

With Sheets("ResultsData")
    ' loop column E untill last cell with value (not entire column)
    For Each Cell In .Range("E1:E" & .Cells(.Rows.Count, "E").End(xlUp).Row)
        If Cell.Value = "0.1" Then
             ' Copy>>Paste in 1-line (no need to use Select)
            .Rows(Cell.Row).Copy Destination:=Sheets("ParsedData").Rows(Cell.Row)
        End If
    Next Cell
End With

End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,890
Office Version
  1. 365
Platform
  1. Windows
Try recording code that:

Applies a filter to sheet ResultsData
Filters column E for values between 0.11 and 0.13
Select the visible data range (Using Select Special to only select the visible cells)
Copy and Paste to ParsedData
Remove the filter from ResultsData

Review the recorded code, make any adjustments, then post back here if still stuck.
 
Solution

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,890
Office Version
  1. 365
Platform
  1. Windows
You're welcome, thanks for the feedback :)
 

Forum statistics

Threads
1,144,611
Messages
5,725,302
Members
422,608
Latest member
bswg5882

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
Top