?
Solved

Mass move info in Excel File

Posted on 2013-12-11
4
Medium Priority
?
314 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
[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
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 52

Accepted Solution

by:
Rgonzo1971 earned 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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 lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

752 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