(Solved) – If Cell Contains This or That Paste onto Another Sheet

(solved)-–-if-cell-contains-this-or-that-paste-onto-another-sheet

I have 2 sheets in my workbook SheetJS and Sheet1. I have this code that partially matches cells in each row that contain the phrase “ABC” in SheetJS and copies them to Column D in Sheet1. It them partially matches cells that contain the phrase “123” in SheetJS and copies then to Column G in Sheet1.

How can I change the code to partially match cells in each row in Sheet1 containing either “ABC” or “132” and pastes the values to Column D in Sheet1?

I will write a similar macro to copy values into Column G in Sheet1

Sub Extract_Data_or()

    For Each cell In Sheets("SheetJS").Range("A1:ZZ200")

        matchrow = cell.Row

        If cell.Value Like "*ABC*" Then 

            Sheets("Sheet1").Range("D" & matchrow).Value = cell.Value

        ElseIf cell.Value Like "*123*" Then

            Sheets("Sheet1").Range("G" & matchrow).Value = cell.Value

        End If

    Next

End Sub

Any tips will help thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *