I have been trying to create a function with copies the next cell and paste data into same cell but i really do not know how to create it.
Any help will be much appreciated.
Dim Lrow As Long
With Sheet1
Lrow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("C2:C" & Lrow).Copy Sheet7.Range("A2")
.Range("I2:I" & Lrow).Copy Sheet7.Range("C2")
.Range("B2:B" & Lrow).Copy Sheet7.Range("D2")
.Range("G2:G" & Lrow).Copy Sheet7.Range("E2")
.Range("S2:S" & Lrow).Copy Sheet7.Range("F2")
.Range("D2:D" & Lrow).Copy Sheet7.Range("H2")
.Range("E2:E" & Lrow).Copy Sheet7.Range("I2")
.Range("L2:L" & Lrow).Copy Sheet7.Range("J2")
.Range("N2:N" & Lrow).Copy Sheet7.Range("K2")
.Range("Q2:Q" & Lrow).Copy Sheet7.Range("L2")
.Range("R2:R" & Lrow).Copy Sheet7.Range("M2")
.Range("M2:M" & Lrow).Copy Sheet7.Range("N2")
End Wit
Give a try to below codes.
Sub MyCopy()
Dim Lrow As Long
With Sheet1
Lrow = .Cells(.Rows.Count, "A").End(xlUp).Row
If Lrow <= 2 Then
Exit Sub
Else
.Range("C" & Lrow).Copy Sheet7.Range("A2")
.Range("I" & Lrow).Copy Sheet7.Range("C2")
.Range("B" & Lrow).Copy Sheet7.Range("D2")
.Range("G" & Lrow).Copy Sheet7.Range("E2")
.Range("S" & Lrow).Copy Sheet7.Range("F2")
.Range("D" & Lrow).Copy Sheet7.Range("H2")
.Range("E" & Lrow).Copy Sheet7.Range("I2")
.Range("L" & Lrow).Copy Sheet7.Range("J2")
.Range("N" & Lrow).Copy Sheet7.Range("K2")
.Range("Q" & Lrow).Copy Sheet7.Range("L2")
.Range("R" & Lrow).Copy Sheet7.Range("M2")
.Range("M" & Lrow).Copy Sheet7.Range("N2")
End If
End With
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.