Copy, Filter paste vba

Asked

Viewed 128 times

1

Guys good afternoon, I need to filter the data in column B containing "Cell 01" And delete the other data from this column.( in VBA ) I have some observations to be made in the project.

1- I need to copy the entire worksheet and paste it into a new file.

2- Keep existing formulas in it.

what I can use?

Follow the image

inserir a descrição da imagem aqui

Thank you

1 answer

4


You can iterate the lines using a statement

For cont = Plan.UsedRange.Rows.Count To 1 Step -1
'Plan é a referência à planilha; cont é uma variável do tipo long.
'Recomendo fazer em ordem decrescente porque em ordem crescente, quando você
'exclui uma linha o excel remunera todas as seguintes para uma a menos, daí o código
'termina indiretamente pulando a próxima linha.

To test the contents of column 2 and delete the respective row, you can use

If Plan.Cells(cont, 2).Formula = "Cell 01" Then Plan.Rows(cont).Delete

To copy the spreadsheet, the instruction is

plan.Copy

I kind of ended up giving you almost complete code, but remember that Stackoverflow is not a code creation service, but to ask questions and ask for clarification. So in the next questions, remember to have some code as a starting point, which you have questions about.

  • Thanks Cesar for the help, and yes I will leave the Cod.

Browser other questions tagged

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