Solved

Mass move info in Excel File

Posted on 2013-12-11
4
293 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

805 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