Solved

Combine elements of a report to create a list

Posted on 2014-03-03
5
125 Views
Last Modified: 2014-03-05
Hi Experts,

A low-tech vendor sends me reports in Excel with the customer name and ID on a different line than the related records.  I want to run a procedure that puts the information identifying the customer on the same line as the invoice data.  In other words, I need to tag the invoice data with the customer ID from Col B and the Customer name from COL D.  The goal is to get a list that can be used for pivot tables or import.

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

Thanks for your help experts!
Carlisle-Sample-File.xlsx
0
Comment
Question by:thutchinson
  • 3
  • 2
5 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 500 total points
Comment Utility
Here's a macro that will do most of that for you. You only need to adjust a couple of the columns and you're all set:

Sub FixStuff()
Dim lLastRow As Long


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


lLastRow = Cells(Rows.Count, 1).End(xlUp).Row

Columns("A:C").Insert

With Cells(1, 4).CurrentRegion
    .AutoFilter
    .AutoFilter 1, "Customer"
    
    Range("A2:C" & lLastRow).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "=RC[4]"
    Range("A2:C" & lLastRow).SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
    
    .AutoFilter
    
    Range("A2:C" & lLastRow).Value = Range("A2:C" & lLastRow).Value
    
    .AutoFilter 1, "Customer"
    
    .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
    
    .AutoFilter
End With

Columns("B").Delete
Cells(1, 1) = "CUST"
Cells(1, 2) = "Customer Name"

With Application
    .ScreenUpdating = True
    .EnableEvents = True
    .Calculation = xlCalculationAutomatic
    .DisplayAlerts = True
End With


End Sub

Open in new window


Thomas
0
 

Author Comment

by:thutchinson
Comment Utility
Thomas,

That is fabulous.  Works great. There's some good code in here.  
How can I learn to do this?
0
 

Author Closing Comment

by:thutchinson
Comment Utility
Thank you. Thank you.-TMH
0
 
LVL 39

Expert Comment

by:nutsch
Comment Utility
You practice a lot. You can check out the Excel VBA for Dummies by John Walkenbach, hang around EE and start trying to answer questions, record some macros and look at the code you get (though it won't be very good code for sure).

You can also hang out at the following sites, as quoted from Brad Yundt:

"A person interested in Excel will find numerous solutions to standard problems on sites run by Chip Pearson http://www.cpearson.com/excel/topic.aspxhttp://www.cpearson.com/excel/topic.aspx, John Walkenbach http://spreadsheetpage.com/index.php/site/tips/, Jon Peltier http://peltiertech.com/, Debra Dalgleish http://contextures.com/tiptech.html, and Ron de Bruin http://www.rondebruin.nl/ "
0
 

Author Comment

by:thutchinson
Comment Utility
Good tips.  Thanks again Thomas.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

762 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

11 Experts available now in Live!

Get 1:1 Help Now