Solved

Convert a report with sub groups to a list

Posted on 2014-03-18
3
171 Views
Last Modified: 2014-03-18
Hello Experts,

I receive large sales reports in Excel that I need to be able to convert to a list. The report is grouped by customer name and ID on a different line than the related records.  I want to run a procedure that extracts the customer name and puts it on the same line as the invoice data.  The goal is to get a list that can be used for pivot tables or import.

Here's the steps that I identified:
-Remove Titles
-Insert new COL A
-Extract Customer name from string
-Populate COL A with the Customer name associated with correct invoice records
-Delete empty rows, subtotals, and section headers
-Anything else that you see wrong.

Attached is a workbook with the bad data that I receive in one tab and the result I need in the other tab.

Thanks for your help experts!
-TH
Add-Customer-to-each-record.xlsx
0
Comment
Question by:thutchinson
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 500 total points
ID: 39938153
Here is a macro that should do all that neatly:

Sub Macro2()
Dim rgData As Range
Dim lLastRow As Long, lRowLoop As Long

'turn off updates to speed up code execution
With Application
    .ScreenUpdating = False
    .EnableEvents = False
    .Calculation = xlCalculationManual
    .DisplayAlerts = False
End With


Rows("1:11").Delete Shift:=xlUp
lLastRow = Cells(Rows.Count, 1).End(xlUp).Row
Columns("A").Insert
    
[a1] = Mid([b1], 12)
Range("A2:A" & lLastRow).FormulaR1C1 = "=if(left(rc[1],8)=""Customer"",right(rc[1],len(rc[1])-11),R[-1]C)"
Range("A1:A" & lLastRow).Value = Range("A1:A" & lLastRow).Value
Rows("1").Delete Shift:=xlUp
[a1] = "Customer"
    
With Range("A1:O" & lLastRow)
    .AutoFilter
    .AutoFilter Field:=8, Criteria1:= _
        "=Plug Cost", Operator:=xlOr, Criteria2:="="
    .Offset(1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
    .AutoFilter
    .Columns.AutoFit
End With
    
With Application
    .ScreenUpdating = True
    .EnableEvents = True
    .Calculation = xlCalculationAutomatic
    .DisplayAlerts = True
End With

End Sub

Open in new window


Thomas
0
 

Author Closing Comment

by:thutchinson
ID: 39938267
Hi Thomas,

Perfection, as usual Thomas. I really appreciate it!

Best,

Todd
0
 
LVL 39

Expert Comment

by:nutsch
ID: 39938302
Glad to help.

THomas
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now