Excel macro 2016 in VBA. Need to copy from 8 separated columns from one sheet to another, in different order. Tried but the Paste is done always in same column A...
I think that this code is self explanatory and easy to modify.
Sub Button1_Click()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Const CopyDataOnly As Boolean = False
Dim c As Long
Dim c1 As String, c2 As String
Dim source As Range, target As Range
With Sheets("Validation by rules")
For c = 0 To 7
c1 = Split("A,B,C,G,F,R,S,T", ",")(c)
c2 = Split("A,B,C,D,E,F,G,H", ",")(c)
Set source = .Range(.Cells(1, c1), .Cells(.Rows.Count, c1).End(xlUp))
Set target = Sheets("TMP").Cells(1, c2)
If CopyDataOnly Then
target.Resize(source.Rows.Count).Value = source.Value
Else
source.Copy target
End If
Next
End With
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub