Solved

Combine elements of a report to create a list

Posted on 2014-03-03
5
133 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 500 total points
ID: 39901528
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
ID: 39901936
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
ID: 39901940
Thank you. Thank you.-TMH
0
 
LVL 39

Expert Comment

by:nutsch
ID: 39901955
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
ID: 39906361
Good tips.  Thanks again Thomas.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

734 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