Solved

Vertical to Horizontal Data in Excel 2013--Large File

Posted on 2016-08-16
10
86 Views
Last Modified: 2016-08-16
I have a large Excel file with about 9000 lines of data.  The data on the sheet is formatted similar to this, but repeats with different names:
Excel Data Vertical
I need to change this to a format similar to this:
Excel Data Horizontal
I will be doing this for multiple years, so on more than just one file.  Is there a batch function that can be run to do this?
0
Comment
Question by:DennisHacker
[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
10 Comments
 
LVL 2

Expert Comment

by:Martin Andrews
ID: 41758303
Not pretty, but if you're willing to fiddle around with your spreadsheet a bit you could try something like the attached.  There's likely a better way, but if your stuck you can use this.
transpose.xls
0
 
LVL 2

Expert Comment

by:Martin Andrews
ID: 41758307
Forgot to mention: if you use this method you'll have to sort by name first!
0
 
LVL 2

Expert Comment

by:Martin Andrews
ID: 41758394
Actually, this is cleaner.  Note: if you update the formula in column E, be sure to press CTRL + SHIFT + ENTER when finished, as it is an array formula.
transpose2.xlsx
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:DennisHacker
ID: 41758398
Martin:  Thanks for the solution.  If my data set was smaller, I may try that, but I simplified what it looks like for illustration purposes on here.  This file has almost 9000 lines in it, and it's one of the smaller ones.  I'm really looking for some kind of script to extract the data, if that's possible.
0
 
LVL 2

Expert Comment

by:Martin Andrews
ID: 41758407
You can easily script it in VBA if you allow that...are all your spreadsheets in that two column file format with no empty rows?
0
 
LVL 2

Assisted Solution

by:Martin Andrews
Martin Andrews earned 500 total points
ID: 41758410
Sorry, I just realized that the second solution was in Sheet 2, not Sheet 1, by the way.
0
 
LVL 7

Expert Comment

by:tomfarrar
ID: 41758444
You could do something like add a helper column and then use a pivot table like the attached.
EE.xlsx
0
 
LVL 2

Accepted Solution

by:
Martin Andrews earned 500 total points
ID: 41758452
You can copy paste your data into this spreadsheet in columns A and B starting at row 2 and then click on Macros and sun the Summarize script.  This will give you the table result you wanted.
transpose3.xlsm
0
 

Author Closing Comment

by:DennisHacker
ID: 41758459
I'll have to edit it because the data isn't that clean...but I get what you did.  Thanks!
0
 
LVL 30

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41758477
Hi Dennis,

Though you have accepted the solution, you may try the below code to transform the data on another tab.
Click the button on Sheet1 to get the desired output.

Sub TransposeData()
Dim sws As Worksheet, dws As Worksheet
Dim i As Long, lc As Long
Dim x, y, z
Dim dict

Application.ScreenUpdating = False

Set sws = Sheets("Sheet1")
On Error Resume Next
Set dws = Sheets("Output")
dws.Cells.Clear
On Error GoTo 0
If dws Is Nothing Then
   Sheets.Add(after:=Sheets(Sheets.Count)).Name = "Output"
   Set dws = ActiveSheet
End If
With dws.Range("A1:B1")
   .Value = Array("Name", "Score 1")
   .Font.Bold = True
   .Font.Size = 12
End With
Set dict = CreateObject("Scripting.Dictionary")
x = sws.Range("A1").CurrentRegion.Value
For i = 2 To UBound(x, 1)
   If Not dict.exists(x(i, 1)) Then
      dict.Item(x(i, 1)) = x(i, 2)
   Else
      dict.Item(x(i, 1)) = dict.Item(x(i, 1)) & ";" & x(i, 2)
   End If
Next i
dws.Range("A2").Resize(dict.Count).Value = Application.Transpose(dict.keys)
y = Application.Transpose(dict.items)
For i = 1 To UBound(y, 1)
   z = Split(y(i, 1), ";")
   dws.Range("B" & i + 1).Resize(1, UBound(z, 1) + 1).Value = Split(y(i, 1), ";")
Next i
lc = dws.UsedRange.Columns.Count
dws.Range("C1").Copy
dws.Range("B2", dws.Cells(UBound(y, 1) + 1, lc)).PasteSpecial Paste:=xlPasteAll, Operation:=xlAdd
dws.Range("B1").AutoFill Destination:=dws.Range("B1", dws.Cells(1, lc)), Type:=xlFillDefault
dws.Range("A1").CurrentRegion.Borders.Color = vbBlack
dws.Columns.AutoFit
dws.Activate
dws.Range("A1").Select
Application.ScreenUpdating = True
End Sub

Open in new window

TransformData_Dennis.xlsm
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
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…

749 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