Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Combine elements of a report to create a list

Posted on 2014-03-03
5
Medium Priority
?
136 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 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

705 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