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

Asked

Viewed 871 times

0

I tried and I keep trying several codes to automate the data copy (column B, spreadsheet proposals) to another spreadsheet (Projects), also in column B, if the F column of the worksheet "proposals" contains the terms "Accepted" or "Sent".

Both worksheets are with the same format. Table header in B3:J3 and data start in B4:Jx

Someone could shed a light?

  • What have you tried to do? Edit the question and present what you have already tried to elaborate.

1 answer

1

You can try the following code, which checks the contents of the F column of the sheet "proposals" and if it equals "Accepted" or "Sent", copies the value of the B column of the sheet "proposals" to the B column of the sheet "Projects". This code stops running when the value in column B of the sheet "proposals" is empty.

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
  • FWIW: Try declaring these variables as Long and not Integer. For with Integer the Spreadsheet hangs when crossing the line 32767.

  • You have a prayer. I had declared how Integer imagining a spreadsheet with few lines. I edited the answer, changing to Long.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.