Hello everyone!
I would like to replace the many lines of code
with a range like
would someone know how to do this please?
I would like to replace the many lines of code
VBA Code:
WS1.Cells(I, "A").Copy: WS2.Cells(Lig, "A").PasteSpecial Paste:=xlPasteValues
with a range like
VBA Code:
WS1.range(I, "A:Q").Copy: WS2.range(Lig, "A:Q").PasteSpecial Paste:=xlPasteValues
would someone know how to do this please?
VBA Code:
Sub copy_paste()
Dim Lig, I As Long
Dim WS1, WS2 As Worksheet
Set WS1 = Worksheets("Feuil1")
Set WS2 = Worksheets("Feuil2")
' appeler une FNC
Ext = ThisWorkbook.Worksheets("Accueil").Range("Concat_Num_FNC").Value
Lig = 4
For I = 2 To WS1.Range("A" & Rows.Count).End(xlUp).Row
If WS1.Cells(I, 1) = Ext Then
WS1.Cells(I, "A").Copy: WS2.Cells(Lig, "A").PasteSpecial Paste:=xlPasteValues
WS1.Cells(I, "B").Copy: WS2.Cells(Lig, "B").PasteSpecial Paste:=xlPasteValues
WS1.Cells(I, "C").Copy: WS2.Cells(Lig, "C").PasteSpecial Paste:=xlPasteValues
WS1.Cells(I, "D").Copy: WS2.Cells(Lig, "D").PasteSpecial Paste:=xlPasteValues
WS1.Cells(I, "E").Copy: WS2.Cells(Lig, "E").PasteSpecial Paste:=xlPasteValues
WS1.Cells(I, "F").Copy: WS2.Cells(Lig, "F").PasteSpecial Paste:=xlPasteValues
WS1.Cells(I, "G").Copy: WS2.Cells(Lig, "G").PasteSpecial Paste:=xlPasteValues
WS1.Cells(I, "H").Copy: WS2.Cells(Lig, "H").PasteSpecial Paste:=xlPasteValues
WS1.Cells(I, "I").Copy: WS2.Cells(Lig, "I").PasteSpecial Paste:=xlPasteValues
WS1.Cells(I, "J").Copy: WS2.Cells(Lig, "J").PasteSpecial Paste:=xlPasteValues
WS1.Cells(I, "K").Copy: WS2.Cells(Lig, "K").PasteSpecial Paste:=xlPasteValues
WS1.Cells(I, "L").Copy: WS2.Cells(Lig, "L").PasteSpecial Paste:=xlPasteValues
WS1.Cells(I, "M").Copy: WS2.Cells(Lig, "M").PasteSpecial Paste:=xlPasteValues
WS1.Cells(I, "N").Copy: WS2.Cells(Lig, "N").PasteSpecial Paste:=xlPasteValues
WS1.Cells(I, "O").Copy: WS2.Cells(Lig, "O").PasteSpecial Paste:=xlPasteValues
WS1.Cells(I, "P").Copy: WS2.Cells(Lig, "P").PasteSpecial Paste:=xlPasteValues
WS1.Cells(I, "Q").Copy: WS2.Cells(Lig, "Q").PasteSpecial Paste:=xlPasteValues
End If
Next I
End Sub