sanjangeorge
asked on
How can i parse this data using VBA in excel? PART 2!
The file shows 5 levels of product information product type, company, color, sub classification and product. Also imagine 100's of product types and 100's of months of data. It all follows the same basic layout throughout.
Beside the product's are monthly sales dollars and units sold. I'd like a flat list of this data for pivot use.
Side note - the file i'm working with has groupings that collapse this data, is there possibly a non vba way of getting a flat list? food for thought
Attached is a file and the code here shows how to get this task done properly with 3 levels of data. (Thanks nutsch)
Beside the product's are monthly sales dollars and units sold. I'd like a flat list of this data for pivot use.
Side note - the file i'm working with has groupings that collapse this data, is there possibly a non vba way of getting a flat list? food for thought
Attached is a file and the code here shows how to get this task done properly with 3 levels of data. (Thanks nutsch)
Private Sub CleanUpAgain()
Dim lastRow As Long, i As Long 'define variables
application.ScreenUpdating = False 'disable ScreenUpdating to avoid screen flashes
lastRow = Cells(Rows.Count, "C").End(xlUp).Row 'get last row
With range("A6:B" & lastRow)
.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
.Value = .Value
End With
Rows("5:6").Delete
Cells(4, 1) = "TYPE"
Cells(4, 2) = "COMPANY"
Cells(4, 3) = "PRODUCT"
With Cells(4, 1).CurrentRegion
.AutoFilter Field:=3, Criteria1:="="
.Offset(1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
.AutoFilter
End With
For i = 4 To Cells(4, Columns.Count).End(xlToLeft).Column
Cells(3, i) = Left(Cells(4, i), Len(Cells(4, i)) - InStr(StrReverse(Cells(4, i)), " "))
Cells(4, i) = Trim(Right(Cells(4, i), InStr(StrReverse(Cells(4, i)), " ")))
Next i
application.ScreenUpdating = True 'reenable ScreenUpdating
End Sub
Example2.xls
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad to help.
Thomas
Thomas
ASKER
I tried to ask you in the previous thread but i guess you weren't notified