Friday, May 1, 2020

Copying multiple columns into one column - vba excel



 Sub MultyCol_to_OneColl ()
Dim arr() As Variant
Dim rng As Range
Dim x As Long
Application.ScreenUpdating = False
arr = Sheets("Sheet1").Range("A2:C100").Value
 For x = LBound(arr, 2) To UBound(arr, 2)
 With Sheets("Sheet1")
Set rng = .Cells(.Rows.Count, 4).End(xlUp).Offset(1)
 rng.Resize(UBound(arr, 1)).Value = Application.Index(arr, , x)
 Set rng = Nothing
End With
Next x
Erase arr
Application.ScreenUpdating = True
 End Sub



Sub MultyCol_to_One_Transpose()
Dim i As Integer
Dim rng As Range
Set rng = Sheet1.Range("C2").CurrentRegion
 For i = 1 To rng.Count
Sheet1.Cells(1 + i, 4) = rng(i)
Next i
End Sub


Sub MultyCol_to_OneColl_transpose()
Dim arr() As Variant
Dim rng As Range
Dim x As Long
Application.ScreenUpdating = False
arr = Sheets("Sheet1").Range("A2:C100").Value
 For x = LBound(arr, 2) To UBound(arr, 2)
 With Sheets("Sheet1")
Set rng = .Cells(.Rows.Count, 4).End(xlUp).Offset(1)
 rng.Resize(UBound(arr, 1)).Value = Application.Index(arr, , x)
 Set rng = Nothing
End With
Next x
Erase arr
Application.ScreenUpdating = True
With Worksheets("sheet1")
.Range(Range("d2"), Range("d2").End(xlDown)).Copy
.Range("e2").PasteSpecial Transpose:=True
.Range(Range("d2"), Range("d2").End(xlDown)).Value = ""
End With
 End Sub

No comments:

Post a Comment

APLIKASI GUDANG VERSI EXCEL VBA

Aplikasi Gudang Sederhana silahkan dikembangkan kritik dan saran membangun selalu kami harapkan FROM ENTRI IURAN BULANA...