Solved

Mass move info in Excel File

Posted on 2013-12-11
4
286 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
ID: 39712373
current data
0
 
LVL 4

Author Comment

by:ITworks
ID: 39712374
what i need
0
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39713544
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
ID: 39714147
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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;…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

920 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

12 Experts available now in Live!

Get 1:1 Help Now