?
Solved

VBA: Reformat data exported from software to excel.

Posted on 2014-01-01
9
Medium Priority
?
246 Views
Last Modified: 2014-01-03
I have attached a file exported from an accounting software to excel which inserts the data and merges cells unnecessarily.

Can someone do a macro for me to convert this format to a more excellish layout?
Reformat-software-output.xls
0
Comment
Question by:Saqib Husain, Syed
[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
  • 5
  • 3
9 Comments
 
LVL 50
ID: 39750728
Hello,

save the file as CSV. Close and re-open. Now you can easily delete empty rows and columns.

cheers, teylyn
0
 
LVL 43

Author Comment

by:Saqib Husain, Syed
ID: 39750797
Thanks, teylyn but I need a macro to do this. I get such a file frequently and I want to put a button on my ribbon which will simply straighten it.
0
 
LVL 43

Author Comment

by:Saqib Husain, Syed
ID: 39750799
Also, it would be good if the macro can do a sum of numbers which can be compared with the provided totals.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 6

Expert Comment

by:ButlerTechnology
ID: 39750874
Can you provide a mock up of what the final results should look like?
0
 
LVL 43

Author Comment

by:Saqib Husain, Syed
ID: 39750879
It should look just the same - but without the extra columns and merged cells
0
 
LVL 6

Expert Comment

by:ButlerTechnology
ID: 39750894
Do you want the merged cells removed starting at B10?
0
 
LVL 43

Author Comment

by:Saqib Husain, Syed
ID: 39750920
Ok I have done a manual format.


***** File edited ********
Desired-format.xls
0
 
LVL 6

Accepted Solution

by:
ButlerTechnology earned 2000 total points
ID: 39750957
Try the following macro -- it is close minus some formatting (I think)

Public Sub Reformat()

Range("B10").Activate
Do
  With ActiveCell
  .Range("R1").Value = .Range("A1").Value
  .Range("S1").Value = .Range("F1").Value
  .Range("T1").Value = .Range("K1").Value
  .Range("U1").Value = .Range("O1").Value
  End With
  ActiveCell.Offset(1, 0).Activate
Loop Until IsEmpty(ActiveCell)

' Labels
Range("S1").Value = Range("B1")
Range("S2").Value = Range("B2")
Range("S3").Value = Range("B3")
Range("S4").Value = Range("B4")
Range("S7").Value = Range("B7")
Range("v7").Value = Range("Q7")

' Totals
  ActiveCell.Offset(1, 0).Activate
  ActiveCell.Range("T1").Value = ActiveCell.Range("K1").Value
  ActiveCell.Range("U1").Value = ActiveCell.Range("O1").Value
  
Range("S1").Activate
Range("A1:R1").EntireColumn.Delete
Range("A1").Activate

' Column Widths
  Range("A1").ColumnWidth = 15
  Range("B1").ColumnWidth = 30
  Range("C1").ColumnWidth = 15
  Range("D1").ColumnWidth = 15
  
  Range("A1:D1").Merge
  Range("A2:D2").Merge
  Range("A3:D3").Merge
  Range("A4:D5").Merge
  Range("A1:D5").HorizontalAlignment = xlCenter
  
  Range("A8").EntireRow.Delete
  Rows("9:9").Font.Bold = True
  
  Columns("C:D").NumberFormat = "$#,##0"
  
  Range("A9").Activate

Do
  ActiveCell.Offset(1, 0).Activate
Loop Until IsEmpty(ActiveCell)
ActiveCell.Offset(2, 2).Activate

Dim Top As Integer
  Top = ActiveCell.Row - 10
  ActiveCell.FormulaR1C1 = "=SUM(R[-" & Top & "]C:R[-3]C)"
  ActiveCell.Offset(0, 1).Activate
  ActiveCell.FormulaR1C1 = "=SUM(R[-" & Top & "]C:R[-3]C)"
  Range("A1").Activate
End Sub

Open in new window

0
 
LVL 43

Author Closing Comment

by:Saqib Husain, Syed
ID: 39753337
Perfect

Thanks
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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;…
This article describes a serious pitfall that can happen when deleting shapes using VBA.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
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…

765 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