tradeaccepted
New Member
- Joined
- Jun 11, 2013
- Messages
- 33
I have an Excel sheet with 30K or so rows of data, all in the column A. Each cell in column A has multiple values that are separated by a semicolon.
I need to get all of these individual values into one column, preferably A.
My current solution is:
Each of the formulas is pretty slow. I found this VBA script which is insanely fast but for some reason, it only copies the first column or two. http://nandeshwar.info/useful-procedures/stack-columns-of-data-on-one-column/
Could anyone provide a better way to complete this task? Also looking to not be limited to 30K rows, some sheets have a lot more than that.
VBA Script 1
VBA Script 2
I need to get all of these individual values into one column, preferably A.
My current solution is:
- Text to Columns with semicolon as the delimiter.
- VBA script to sort all columns in the sheet, one column at a time, A-Z.
- This is used because the following script does not skip blanks, therefore hitting the cell limit for a column.
- VBA script to stack all columns into row A.
- This script is inefficient because I have to state each column that I want to stack into an Array.
Each of the formulas is pretty slow. I found this VBA script which is insanely fast but for some reason, it only copies the first column or two. http://nandeshwar.info/useful-procedures/stack-columns-of-data-on-one-column/
Could anyone provide a better way to complete this task? Also looking to not be limited to 30K rows, some sheets have a lot more than that.
VBA Script 1
Code:
Sub Sort750Columns()
Dim x As Long, y As Long
On Error Resume Next
For x = 1 To 750 'loop thru columns
y = Cells(Rows.Count, x).End(xlUp).Row 'count rows in each column
Range(Cells(3, x), Cells(y, x)).Sort Key1:=Cells(3, x), Order1:=xlAscending, Header:=xlYes
Next x
End Sub
VBA Script 2
Code:
Sub multiple_columns_to_one()'
' multiple_columns_to_one Macro
'
' This will take all values from Columns B to BZ and stack them into column A.
Dim K As Long, ar
K = 1
For Each ar In Array("B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "AA", "AB", "AC", "AD", "AE", "AF", "AG", "AH", "AI", "AJ", "AK", "AL", "AM", "AN", "AO", "AP", "AQ", "AR", "AS", "AT", "AU", "AV", "AW", "AX", "AY", "AZ", "BA", "BB", "BC", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BK", "BL", "BM", "BN", "BO", "BP", "BQ", "BR", "BS", "BT", "BU", "BV", "BW", "BX", "BY", "BZ")
For i = 1 To 10000
If Cells(i, ar).Value <> "" Then
Cells(K, "A").Value = Cells(i, ar).Value
K = K + 1
End If
Next i
Next ar
End Sub