Copy data from one column (B) to another worksheet, if column (F) condition is met. excel

0

I have tried and continue to try various codes to automate the copying of data (column B, worksheet proposals) to another worksheet, also in column B, if column F of the "proposals" spreadsheet contains the terms "Accepts" or "Sent".

Both worksheets have the same formatting. Table header in B3: J3 and start of data in B4: Jx

Could someone give a light?

    
asked by anonymous 16.05.2018 / 13:49

1 answer

1

You can try the following code, which verifies the contents of column F of the "proposals" spreadsheet and if it is the same as "Accepted" or "Sent", copies the value of column B of the proposals spreadsheet to column B of the "projects" worksheet. This code stops executing when the B column value of the proposals spreadsheet is blank.

Dim i As Long
Dim j As Long

i = 4
j = 4

While (Worksheets("proposals").Cells(i, 2) <> "")
    If (Worksheets("proposals").Cells(i, 6) = "Aceita" Or Worksheets("proposals").Cells(i, 6) = "Enviada") Then
        Worksheets("projects").Cells(j, 2) = Worksheets("proposals").Cells(i, 2)
        j = j + 1
    End If
    i = i + 1
Wend
    
16.05.2018 / 14:20