Solved

Mass move info in Excel File

Posted on 2013-12-11
4
284 Views
Last Modified: 2013-12-12
I have a large Excel file that contains some data in it horizontally, that I need changed to vertically.  Not as simple as I just said, so I will try to explain.  The original file has a unique p21lot number in column A, then a letter symbol that represents a chemical in column B, then a number in column C which is the actual number of the chemical in column B.  Column D would have the next chemical abbreviation, Column E would have the actual number for the chemical in column D, etc., etc.  Some p21 lot numbers have a couple of chemicals, while others may have 16.  In my sample, you may notice that it appears that the chemicals are always in the same location.....C is the first one, MN is the second, etc. but this is NOT the case.  So using a pivot table was not a solution for me.  What I need to do with this information is  have column A display the p21 lot number, column b show the chemical name and column c show the actual result. So there would be multiple rows with the same p21 lot number based on the number of chemicals.
I'd like to know if someone knows of an easy way to do this.  I have 5000 lot numbers that need this done and doing it by hand is not only going to be time consuming but I fear I would make errors.
I have attached a sample.  One tab has current data and the other tab shows what I need it to look like.
EE-Sample.xlsx
0
Comment
Question by:ITworks
  • 3
4 Comments
 
LVL 4

Author Comment

by:ITworks
Comment Utility
current data
0
 
LVL 4

Author Comment

by:ITworks
Comment Utility
what i need
0
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
Comment Utility
Hi,

pls try

Sub macro()
Application.ScreenUpdating = False
myCalc = Application.Calculation
Application.Calculation = xlCalculationManual
    ActiveWorkbook.Worksheets("Current").Copy After:=Sheets(Sheets.Count)
    Set ResultSht = Sheets(Sheets.Count)
    ResultSht.Name = "Result"
    With Cells.Interior
        .Pattern = xlNone
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    Rows("1:1").Delete Shift:=xlUp
    Range("B1").Value = "CHEM"
    Range("C1").Value = "ACTUAL"
    Range("D1").Resize(1, 256).ClearContents
    Set RowCell = Range("A2")
    Do Until RowCell.Value = ""
        Set ColCell = RowCell.Offset(0, 3)
        Do Until ColCell = ""
                RowCell.EntireRow.Copy
                RowCell.Offset(1, 0).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
                RowCell.Offset(0, 3).Resize(1, 256).ClearContents
                RowCell.Offset(1, 1).Resize(1, 2).Delete Shift:=xlToLeft
                Set RowCell = RowCell.Offset(1, 0)
                Set ColCell = RowCell.Offset(0, 3)
        Loop
        Set RowCell = RowCell.Offset(1, 0)
        Set ColCell = RowCell.Offset(0, 3)
    Loop
    For Idx = Range("A" & Rows.Count).End(xlUp).Row To 2 Step -1
        If Cells(Idx, 3) = "" Then
            Cells(Idx, 3).EntireRow.Delete
        End If
    Next
Application.Calculation = myCalc
Application.ScreenUpdating = True
End Sub

Open in new window

Regards
0
 
LVL 4

Author Closing Comment

by:ITworks
Comment Utility
AWESOME!    You have saved me 40 hours of manual labor of cutting and pasting.   I wish I could award you more points!    Thanks so much!

Sue
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

771 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