Copy a row based on the value of a cell
Vdel
-
Vdel -
Vdel -
Hello,
Despite my research, I haven't found what I was looking for, so I'm reaching out to you today.
Here is my problem:
I would like to copy the lines from my sheet 1 to sheet 2 every time the value "x" appears in column A of sheet 1.
I’m a beginner in VBA and I'm a bit stuck...
Thank you in advance for your help.
Configuration: Android / Opera Next 52.3.2517.140547
Despite my research, I haven't found what I was looking for, so I'm reaching out to you today.
Here is my problem:
I would like to copy the lines from my sheet 1 to sheet 2 every time the value "x" appears in column A of sheet 1.
I’m a beginner in VBA and I'm a bit stuck...
Thank you in advance for your help.
Configuration: Android / Opera Next 52.3.2517.140547
3 answers
-
Hello,
Is it a copy of the row containing an "x" in column A or should we move this row to sheet 2, in which case it would be deleted from sheet 1?
In the meantime, here's an example with the copy
https://mon-partage.fr/f/0d9yd7ss/
The code used:Option Compare Text Option Explicit Sub Recopie() Dim f1 As Worksheet, f2 As Worksheet Dim DerLig_f1 As Long, Derlig_f2 As Long, DerCol_f1 As Long Dim i As Long Application.ScreenUpdating = False Set f1 = Sheets("Feuil1") Set f2 = Sheets("Feuil2") DerLig_f1 = f1.[A100000].End(xlUp).Row DerCol_f1 = [xfd1].End(xlToLeft).Column Derlig_f2 = f2.[A10000].End(xlUp).Row + 1 For i = 1 To DerLig_f1 If f1.Cells(i, "A") = "x" Then f1.Range(Cells(i, "B"), Cells(i, DerCol_f1)).Copy Destination:=f2.Cells(Derlig_f2, "A") Derlig_f2 = Derlig_f2 + 1 End If Next i Set f1 = Nothing Set f2 = Nothing End Sub
Regards