Move Data from Multiple Cells to New Workbook

TrainerMan

New Member
Joined
May 24, 2012
Messages
4
Hello all. Just FYI, I'm not really experienced with VBA but know a few of the basics. First of all, here's my original data:

Excel 2010
BCDEFG
5DESCRIPTION1009110112011202
660010SALARY AND WAGES339,845493,334218,351100,176
760020EMPLOYEE BENEFITS86,276124,25077,60829,495
860101DUES AND MEMBERSHIPS100000
960102WORKSHOPS/TRAINING5,000500200400
1060199MISC STAFF DEVELOPMENT2,47550500
1160201RENT15,17722,02810,5743,483
1260202UTILITIES2,6363,8271,837545
1360230TELEPHONE 9671,403674197
1460232CELL PHONES/PAGERS20,652001,100
1560233INTERNET/DATA1,3351,936929219
1660240FACILITY CLEANING56181239044
1760250RENOVATIONS0000
1860261REPAIRS/MAINTENANCE23333816258
1960262BLDG MAINTENANCE CONTRACTS8011,163559122
2060299MISC FACILITY EXPENSE36532511

<COLGROUP><COL><COL><COL><COL><COL><COL><COL></COLGROUP><THEAD>
</THEAD><TBODY>
</TBODY>
Sheet1



There are several things i need to do with this data. First, I need to create a 13 digit number in this format: 0000-00000-0000. The first four digits would come from cell D5 (and E5 the next time, etc)... the next five digits would come from cell B6 (and B7 the next time, etc)... the last four digits will always be 0000. I know I can use the following to accomplish that: =D5&"-"&B6&"-"&0000 but I can never get the four zeros to stay... it always reduces it to one zero. When I change the cell formatting, that just makes the cell display the formula instead of the result.

I'll try to be succinct, but I have several other things that need to happen. Let me show you what the desired output:

Excel 2010
ABCDEFGHIJKLMNOP
3AccountDescriptionBeginning Balance - 2013Period 1 - 2013Period 2 - 2013Period 3 - 2013Period 4 - 2013Period 5 - 2013Period 6 - 2013Period 7 - 2013Period 8 - 2013Period 9 - 2013Period 10 - 2013Period 11 - 2013Period 12 - 2013Total
41009-60101-0000DUES AND MEMBERSHIPS0.008.338.338.338.338.338.338.338.338.338.338.338.37100

<COLGROUP><COL><COL><COL><COL><COL><COL><COL><COL><COL><COL><COL><COL><COL><COL><COL><COL><COL></COLGROUP><THEAD>
</THEAD><TBODY>
</TBODY>
SAMPLE_BUDGET



As you will notice, I need that 13 digit number in column A. Then column B needs to contain data from column C in the original worksheet. Then the number in D6 on the original worksheet is the total budgeted for one year, so that needs to go in column P on the new worksheet and then split 12 ways in columns D - O. Unfortunately, it doesn't usually split evenly to the cent, so the 12th month will probably need to be entered manually (unless there's a way to make this happen automatically as well).

So that's one row done on the new worksheet. Then that process needs to be repeated with data from E5, B6, C6, E6... then on down the line. I'm just looking for a way to have this happen automatically, or at least more quickly than manually entering everything. Sorry, I feel like I'm struggling to explain this well, so please ask if you have any questions. I'd be forever grateful if you could help at all! Thanks!

TrainerMan
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Maybe if you can at least put 3 or 4 rows of data (the expected output)

Cos am a little ocnfused here - (D5-b6,E5-b7,f5-b8) or how does that go? and which column appears in the Total column, i sit always from column D on the old spreadsheet??
 
Upvote 0
I knew I wasn't explaining things in the most clear of ways. Sorry! So the number generated in cell A4 of SAMPLE_BUDGET comes from cells D5 and B8 of Sheet1 with 4 zeros added on. Then the text in B4 of SAMPLE_BUDGET comes from cell C8 of Sheet1. Then cell P4 of SAMPLE_BUDGET comes from cell D8 of Sheet1. And the last thing that needs to happen is that value in P4 needs to be split 12 ways in cells D4 - O4. It's a dollar amount, so it needs to come out evenly to the cent... that's why cell O4 may have to be manually input because if I just put in the formula =$P$4/12 in cells D4 - O4, the total comes out to 99.96, but it needs to be 100.

Does that explanation help at all? Here's more data for the expected output:

Excel 2010
ABCDEFGHIJKLMNOP
3AccountDescriptionBeginning Balance - 2013Period 1 - 2013Period 2 - 2013Period 3 - 2013Period 4 - 2013Period 5 - 2013Period 6 - 2013Period 7 - 2013Period 8 - 2013Period 9 - 2013Period 10 - 2013Period 11 - 2013Period 12 - 2013Total
41009-60101-0000DUES AND MEMBERSHIPS0.008.338.338.338.338.338.338.338.338.338.338.338.37100
51009-60102-0000WORKSHOPS/TRAINING0.00416.67416.67416.67416.67416.67416.67416.67416.67416.67416.67416.67416.635000.00
61009-60199-0000MISC STAFF DEVELOPMENT0.00206.25206.25206.25206.25206.25206.25206.25206.25206.25206.25206.25206.252475.00
71009-60201-0000RENT0.001264.751264.751264.751264.751264.751264.751264.751264.751264.751264.751264.751264.7515177.00
81009-60202-0000UTILITIES0.00219.67219.67219.67219.67219.67219.67219.67219.67219.67219.67219.67219.632636.00

<COLGROUP><COL><COL><COL><COL><COL><COL><COL><COL><COL><COL><COL><COL><COL><COL><COL><COL><COL></COLGROUP><THEAD>
</THEAD><TBODY>
</TBODY>
SAMPLE_BUDGET
 
Upvote 0
One other thing to mention is that once I'm done with 1009 and numbers from column B, I have to then do 1101 and numbers from column B... and so on. Does that make sense?
 
Upvote 0
Lets see if we can get 90/100th of the way.

Give this macro a try:

Code:
Sub rearrangedata()
    Dim I As Integer
    Dim j As Integer
    lastrow = Range("C1").End(xlDown).Row
    lastcol = Range("A1").End(xlToRight).Column
    lastrow2 = 2
    Set wksold = ActiveWorkbook.ActiveSheet
    Set wks = Worksheets.Add()
    wks.Name = "Newwks"
    wks.Range("A1:P1").Value = Array("Account", "Description", "Beginning Balanace - 2013", "period 1 - 2013" _
    , "Period 2 - 2013", "Period 3 - 2013", "Period 4 - 2013", "Period 5 - 2013", "Period 6 - 2013", "Period 7 - 2013", _
    "Period 8 - 2013", "Period 9 - 2013", "Period 10 - 2013", "Period 11 - 2013", "Period 12 - 2013", "Total")
    
    For I = 2 To lastrow
        For j = 4 To lastcol
            With wks
                .Cells(lastrow2, 1).Value = wksold.Cells(1, j).Value & "-" & wksold.Cells(I, 2).Value & "-" & "00000"
                .Cells(lastrow2, "B").Value = wksold.Cells(I, 3).Value
                .Cells(lastrow2, "C").Value = 0
                
                With .Cells(lastrow2, "P")
                .Value = wksold.Cells(I, j).Value
                .NumberFormat = "#,##0.00"
                End With
                
                With .Range(Cells(lastrow2, "D"), Cells(lastrow2, "O"))
                .Value = wksold.Cells(I, j).Value / 12
                .NumberFormat = "#,##0.00"
                End With
                
            End With
            lastrow2 = lastrow2 + 1
        Next j
    Next I
    Columns("A:P").EntireColumn.AutoFit
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,543
Messages
6,125,429
Members
449,223
Latest member
Narrian

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top