Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub ColumnsToOne()
- Dim i As Integer
- Dim Lastrow As Long
- Dim Lastrowb As Long
- LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column
- Lastrow = Cells(Rows.Count, "A").End(xlUp).Row + 1
- For i = 2 To LastColumn
- Lastrowb = Cells(Rows.Count, i).End(xlUp).Row
- Range(Cells(1, i), Cells(Lastrowb, i)).Copy Destination:=Cells(Lastrow, 1)
- Lastrow = Cells(Rows.Count, "A").End(xlUp).Row + 1
- Next
- End Sub
- Sub CombineColumns1()
- Dim xRng As Range
- Dim i As Integer
- Dim xLastRow As Integer
- Dim xTxt As String
- On Error Resume Next
- xTxt = Application.ActiveWindow.RangeSelection.Address
- Set xRng = Application.InputBox("please select the data range", "ColumnToOne", xTxt, , , , , 8)
- If xRng Is Nothing Then Exit Sub
- xLastRow = xRng.Columns(1).Rows.Count + 1
- For i = 2 To xRng.Columns.Count
- Range(xRng.Cells(1, i), xRng.Cells(xRng.Columns(i).Rows.Count, i)).Cut
- ActiveSheet.Paste Destination:=xRng.Cells(xLastRow, 1)
- xLastRow = xLastRow + xRng.Columns(i).Rows.Count
- Next
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement