0
votes

I have a table "RawData" in excel I would like to filter. Column A has a name, and Column B has a number. I would like to copy the data to a different table, "LoadingData", if the name matches up with a specific number. I have the corresponding names/numbers in a different tab "ShiftData" within the worksheet.

EX. If John Smith has a 2 in the column next to him, copy the whole row to sheet "LoadingData". If John Smith has a 4 in the column next to him, do not move his data.

I tried using a VLOOKUP function, but I think what I'm trying to do is more complicated than that. Any help would be appreciated!

1
show what've you done so far - BobSki
you may need vba to copy and paste in different sheets if that is what you really need - Gowtham Shiva

1 Answers

0
votes
Sub CopyData()
Const cValuetoCheck = 2
Dim rngData As Range, rngLoad As Range

    Set rngData = Worksheets("shiftdata").Range("B1")
    Set rngLoad = Worksheets("loadingdata").Range("A1")

    While Not (IsEmpty(rngData))
        If rngData = cValuetoCheck Then
            rngData.EntireRow.Copy
            rngLoad.EntireRow.PasteSpecial
            Set rngLoad = rngLoad.Offset(1, 0)
        End If
        Set rngData = rngData.Offset(1, 0)
    Wend

End Sub