A macro to consolidate many budgets into summary sheet

Kim B

Board Regular
Joined
Jun 16, 2008
Messages
221
Office Version
  1. 365
Hello all. I have tried to take code from other board posts and make it work with what I am trying to do and am failing miserably. This macro is not that difficult, at least I don't think so compared to what I have seen done. I have 100 budgets that need to be consolidated into a seperate summary sheet. Column D5 on the first html, will determine what dept the budget comes from. So column b on the second html will change when the range has been exhausted on each budget. The range is B9:B132 from the first html. The directory in which the budgets are stored is g:\accounting\private\msdacct\planning\2011\budgets\budgets reviewed.

Thanks in advance

Excel Workbook
BCDEFGH
1
2
3
4
5DEPARTMENT: 69311INFORMATION SYSTEMS
6MANAGER:
7
8ACCOUNTDESCRIPTIONQ1Q2Q3Q42010
9502104 - UAOTH NON-OH EXP - TAXES0
10511101 - UASALARY & WAGE - INDIRECT LABOR96,98099,24199,24199,241394,703
11513004 - UAEMPLOYEE - TRAINING3,5003,5003,5003,50014,000
12520001 - UATRAVEL EXPENSE - TRANSPORT AIR3,0003,0003,0003,00012,000
13520002 - UATRAVEL EXPENSE - TRNSPORT LAND1,2001,2001,2001,2004,800
14520003 - UATRAVEL EXPENSE - ACCOMMODATION3,0003,0003,0003,00012,000
15520004 - UATRAVEL EXPENSE - MEALS1,0801,0801,0801,0804,320
16520005 - UATRAVEL EXPENSE - ENTERTAINMENT0
17520007 - UATRAVEL EXPENSE - GENERAL200200200200800
18531003 - UARENTS - OFFICE EQUIPMENTS0
19531012 - UAREPAIR & MAINTENANCE - MACH1,7501,7501,7501,7507,000
20531013 - UAREPAIR & MAINTENANCE0
21531091 - UACOMMODITY - PPV0
22531201 - UATELEPHONE10,04510,04510,04510,04540,180
23531203 - UAIT NETWORK12,87510,45010,45010,45044,224
24531204 - UASOFTWARE8,9148,3828,3829,38235,061
25531411 - UANON-OPERATING SUPPLIES4254254254251,700
26532103 - UAOUTSOURCED SERVICE - ACCOUNTIN0
27532104 - UAOUTSOURCED SERVICES - OTHER0
28532105 - UAOUTSOURCED SERVICE - CONSULTIN25,00023,00025,00020,00093,000
29552101 - UAFREIGHT - INBOUND75757575300
30552201 - UAFREIGHT - OUTBOUND150150150150600
31591501 - UADEPRECIATION - EQUIPMENT34,32831,79331,79329,355127,269
1090
1100
1110
1120
1130
1140
1150
1160
1170
1180
1190
1200
1210
122512001DIRECT - SOCIAL SECURITY00000
123512002DIRECT - UNEMPLOYMENT INSURANC00000
124512005DIRECT - MEDICAL00000
125512006DIRECT - LIFE INSURANCE00000
126512101INDIRECT - SOCIAL SECURITY7,4197,5927,5927,59230,195
127512102INDIRECT - UNEMPLOYMENT INSUR1,5451,5451,5451,5456,180
128512105INDIRECT - MEDICAL13,01713,01713,01713,01752,069
129512106INDIRECT - LIFE INSURANCE8948948948943,575
130512201DIRECT - 401K00000
131512301INDIRECT - 401K6,8376,9966,9966,99627,824
132TOTAL232,232227,335229,335222,896911,799
Budget




And consolidate into this

Excel Workbook
ABCDEFGHI
2UA11111503201LABOR ABSORPTION(128,262)(120,008)(109,641)(111,789) (469,700.00)
3UA11111511001SALARY & WAGE - DIRECT LABOR96,67490,45366,11267,406 320,645.50
4UA11111511003VACATION - DIRECT LABOR2,91310,19614,72712,462 40,298.16
5UA11111511007SAL&WAGE PREMIUM-DIRECT LABOR4,3944,1123,0053,064 14,574.80
6UA11111511101SALARY & WAGE - INDIRECT LABOR15,52115,98715,98715,987 63,481.02
7UA11111511107SAL&WAGE PREMIUM-INDIRECT LAB1,0001,0001,0001,000 4,000.00
8UA11111531012REPAIR & MAINTENANCE - MACH250250250250 1,000.00
9UA11111531306NON-CAPITALIZED TOOLS800800800800 3,200.00
10UA11111531399CHEMICAL - OPERATING SUPPLIES3,0003,0003,0003,000 12,000.00
11UA11111531401OPERATING SUPPLIES3,0003,0003,0003,000 12,000.00
12UA11111531411NON-OPERATING SUPPLIES2,0002,0002,0002,000 8,000.00
13UA11111532104OUTSOURCED SERVICES - OTHER150150150150 600.00
14UA11111591101DEPRECIATION - MACHINES35,88035,33535,33435,335 141,882.68
15UA11111512001DIRECT - SOCIAL SECURITY7,9558,0146,4146,344 28,727.16
16UA11111512002DIRECT - UNEMPLOYMENT INSURANC2,7812,7812,1632,163 9,887.20
17UA11111512005DIRECT - MEDICAL23,43123,43118,22418,224 83,309.65
18UA11111512006DIRECT - LIFE INSURANCE1,6091,6091,2511,251 5,720.00
19UA11111512101INDIRECT - SOCIAL SECURITY1,2641,2991,2991,299 5,162.30
20UA11111512102INDIRECT - UNEMPLOYMENT INSUR309309309309 1,235.90
21UA11111512105INDIRECT - MEDICAL2,6032,6032,6032,603 10,413.71
22UA11111512106INDIRECT - LIFE INSURANCE179179179179 715.00
23UA11111512201DIRECT - 401K7,3307,3855,9115,846 26,471.80
24UA11111512301INDIRECT - 401K1,1651,1971,1971,197 4,757.01
25UA11121503201LABOR ABSORPTION (234,120.99)(219,016)(200,136)(203,912) (857,184.90)
26UA11121511001SALARY & WAGE - DIRECT LABOR 203,945.14190,787174,340177,630 746,702.36
27UA11121511003VACATION - DIRECT LABOR 2,858.812,2402,0462,085 9,229.84
28UA11121511007SAL&WAGE PREMIUM-DIRECT LABOR 2,970.072,3272,1262,166 9,589.07
29UA11121511101SALARY & WAGE - INDIRECT LABOR 22,851.0023,53623,53623,536 93,459.00
30UA11121511107SAL&WAGE PREMIUM-INDIRECT LAB 200.00200200200 800.00
31UA11121520001TRAVEL EXPENSE - TRANSPORT AIR 500.00500 1,000.00
32UA11121520003TRAVEL EXPENSE -ACCOMODATIONS 500.00500 1,000.00
33UA11121520004TRAVEL EXPENSE -MEALS 250.00250 500.00
34UA11121531012REPAIR & MAINTENANCE - MACH 350.00350350350 1,400.00
35UA11121531013REPAIR & MAINTENANCE 1,000.001,0001,0001,000 4,000.00
36UA11121531303OFFICE SUPPLIES 50.00505050 200.00
37UA11121531399CHEMICAL - OPERATING SUPPLIES 1,000.001,0001,0001,000 4,000.00
38UA11121531400PAINT - OPERATING SUPPLIES 250.00250250250 1,000.00
39UA11121531401OPERATING SUPPLIES 3,500.003,5003,5003,500 14,000.00
40UA11121531404OUTSIDE OPERATION EXPENSES 5,000.005,0005,0005,000 20,000.00
41UA11121531411NON-OPERATING SUPPLIES 2,500.002,5002,5002,500 10,000.00
42UA11121552201FREIGHT - OUTBOUND 500.00500500500 2,000.00
43UA11121591101DEPRECIATION - MACHINES 29,439.0029,43929,43929,057 117,374.00
44UA11121512001DIRECT - SOCIAL SECURITY 16,047.7114,94513,65613,914 58,562.38
45UA11121512002DIRECT - UNEMPLOYMENT INSURANC 5,870.535,8715,8715,871 23,482.10
46UA11121512005DIRECT - MEDICAL 49,465.1149,46549,46549,465 197,860.43
47UA11121512006DIRECT - LIFE INSURANCE 3,396.253,3963,3963,396 13,585.00
48UA11121512101INDIRECT - SOCIAL SECURITY 1,763.401,8161,8161,816 7,210.81
49UA11121512102INDIRECT - UNEMPLOYMENT INSUR 617.95618618618 2,471.80
50UA11121512105INDIRECT - MEDICAL 5,206.855,2075,2075,207 20,827.41
51UA11121512106INDIRECT - LIFE INSURANCE 357.50358358358 1,430.00
52UA11121512201DIRECT - 401K 14,787.8113,77112,58412,822 53,964.66
53UA11121512301INDIRECT - 401K 1,624.961,6731,6731,673 6,644.69
54UC11123502104OTH NON-OH EXP - TAXES 750.00750750750 3,000.00
Data
 
I fixed the sheet referrence error. Budgets is on sheet 3 instr are on 1. It is skipping budgets centers as it runs through the directory. I think it is because some of them have links. Is there a way to tell the code to ignore the links. I am watching it as it is referrencing each budget and answering continue on the links question but it doesn't seem to be pulling those budgets in.

Sub multicopy()
' get first file
fname = Dir("g:\accounting\private\msdacct\planning\2011\plan\budgets\budgets reviewed\*.xl*")
Do Until fname = ""
Workbooks.Open (fname)
Sheets("Budget").Select
lastrow = ActiveWorkbook.Sheets(1).Range("B65536").End(xlUp).Row
targetrow = ThisWorkbook.Sheets(1).Range("B65536").End(xlUp).Offset(1).Row
ActiveWorkbook.Sheets(3).Range("B9:H" & lastrow).Copy _
Destination:=ThisWorkbook.Sheets(1).Range("B" & targetrow)
ThisWorkbook.Sheets(1).Range("A" & targetrow).Resize(lastrow - 9 + 1).Value = _
ActiveWorkbook.Sheets(3).Range("D5").Value
ActiveWorkbook.Close savechanges:=False
fname = Dir
Loop

End Sub
 
Upvote 0

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
If you step through the code, and watch what it's doing, is it opening those files? And if so can you add Watches for lastrow and targetrow and see what happening with those as the stepping goes on? A little debugging like this may throw some light on what's going on.

( to add a Watch, an easy way is to start the stepping through the macro, and highlight a variable in a line of code, right click and choose Add Watch ... you should see the variable in a Watch Window, and you'll be able to see the values of the variables as the code executes )
 
Upvote 0
Part of the problem was that not all the budget tabs were in the 3rd position. I wasn't aware of this. I fixed them all now so they are all on the 3 tab of each workbook. We are getting close. Here is the latest result. As you can see, sometimes it picks up the fields and sometimes it doesn't. The result showing in dept 21166 is perfect and what the macro should be generating


Sheet1

<TABLE style="BACKGROUND-COLOR: #ffffff; PADDING-LEFT: 2pt; PADDING-RIGHT: 2pt; FONT-FAMILY: Tahoma,Arial; FONT-SIZE: 10pt" border=1 cellSpacing=0 cellPadding=0><COLGROUP><COL style="WIDTH: 30px; FONT-WEIGHT: bold"><COL style="WIDTH: 129px"><COL style="WIDTH: 169px"><COL style="WIDTH: 241px"><COL style="WIDTH: 81px"><COL style="WIDTH: 141px"><COL style="WIDTH: 74px"><COL style="WIDTH: 81px"><COL style="WIDTH: 64px"></COLGROUP><TBODY><TR style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt; FONT-WEIGHT: bold"><TD></TD><TD>A</TD><TD>B</TD><TD>C</TD><TD>D</TD><TD>E</TD><TD>F</TD><TD>G</TD><TD>H</TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">89</TD><TD style="TEXT-ALIGN: right">11121</TD><TD></TD><TD></TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">3,500 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">3,500 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">3,500 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">3,500 </TD><TD style="TEXT-ALIGN: right">14,000 </TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">90</TD><TD style="TEXT-ALIGN: right">11121</TD><TD></TD><TD></TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">5,000 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">5,000 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">5,000 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">5,000 </TD><TD style="TEXT-ALIGN: right">20,000 </TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">91</TD><TD style="TEXT-ALIGN: right">11121</TD><TD></TD><TD></TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">2,500 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">2,500 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">2,500 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">2,500 </TD><TD style="TEXT-ALIGN: right">10,000 </TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">92</TD><TD style="TEXT-ALIGN: right">11131</TD><TD></TD><TD></TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">0 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">0 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">0 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">0 </TD><TD style="TEXT-ALIGN: right">0 </TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">93</TD><TD style="TEXT-ALIGN: right">11131</TD><TD></TD><TD></TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">0 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">0 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">0 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">0 </TD><TD style="TEXT-ALIGN: right">0 </TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">94</TD><TD style="TEXT-ALIGN: right">21111</TD><TD></TD><TD></TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">360 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">360 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">360 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">360 </TD><TD style="TEXT-ALIGN: right">1,440 </TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">95</TD><TD style="TEXT-ALIGN: right">21111</TD><TD></TD><TD></TD><TD style="BACKGROUND-COLOR: #ffff99"></TD><TD style="BACKGROUND-COLOR: #ffff99"></TD><TD style="BACKGROUND-COLOR: #ffff99"></TD><TD style="BACKGROUND-COLOR: #ffff99"></TD><TD style="TEXT-ALIGN: right">0 </TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">96</TD><TD style="TEXT-ALIGN: right">21121</TD><TD></TD><TD></TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">250 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">250 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">250 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">250 </TD><TD style="TEXT-ALIGN: right">1,000 </TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">97</TD><TD style="TEXT-ALIGN: right">21123</TD><TD></TD><TD></TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">450 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">450 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">450 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">450 </TD><TD style="TEXT-ALIGN: right">1,800 </TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">98</TD><TD style="TEXT-ALIGN: right">21123</TD><TD></TD><TD></TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">450 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">450 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">450 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">450 </TD><TD style="TEXT-ALIGN: right">1,800 </TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">99</TD><TD style="TEXT-ALIGN: right">21123</TD><TD></TD><TD></TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">250 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">250 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">250 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">250 </TD><TD style="TEXT-ALIGN: right">1,000 </TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">100</TD><TD style="TEXT-ALIGN: right">21124</TD><TD></TD><TD></TD><TD style="BACKGROUND-COLOR: #ffff99"></TD><TD style="BACKGROUND-COLOR: #ffff99"></TD><TD style="BACKGROUND-COLOR: #ffff99"></TD><TD style="BACKGROUND-COLOR: #ffff99"></TD><TD style="TEXT-ALIGN: right">0 </TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">101</TD><TD style="TEXT-ALIGN: right">21124</TD><TD></TD><TD></TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">21,437 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">21,873 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">21,873 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">21,961 </TD><TD style="TEXT-ALIGN: right">87,144 </TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">102</TD><TD></TD><TD>INDIRECT - LIFE INSURANCE</TD><TD style="FONT-FAMILY: Arial">#REF!</TD><TD></TD><TD></TD><TD style="FONT-FAMILY: Arial"></TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">103</TD><TD></TD><TD>DIRECT - 401K</TD><TD></TD><TD style="TEXT-ALIGN: right; FONT-FAMILY: Arial">0.0705 </TD><TD></TD><TD></TD><TD style="FONT-FAMILY: Arial"></TD><TD></TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">104</TD><TD></TD><TD>INDIRECT - 401K</TD><TD></TD><TD style="TEXT-ALIGN: right; FONT-FAMILY: Arial">0.0705 </TD><TD></TD><TD></TD><TD style="FONT-FAMILY: Arial"></TD><TD></TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">105</TD><TD style="TEXT-ALIGN: right">21151</TD><TD></TD><TD></TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">12,615 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">12,615 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">11,890 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">9,949 </TD><TD style="TEXT-ALIGN: right">47,069 </TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">106</TD><TD style="TEXT-ALIGN: right">21166</TD><TD style="FONT-FAMILY: Andale WT">511101 - UA</TD><TD style="TEXT-ALIGN: left; FONT-FAMILY: Andale WT">SALARY & WAGE - INDIRECT LABOR</TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">38,039 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">57,901 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">67,552 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">67,552 </TD><TD style="TEXT-ALIGN: right">231,043 </TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">107</TD><TD style="TEXT-ALIGN: right">21166</TD><TD style="FONT-FAMILY: Andale WT">532102 - UA</TD><TD style="TEXT-ALIGN: left; FONT-FAMILY: Andale WT">OUTSOURCED SERVICE - AUDITING</TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">6,500 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">6,500 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">6,500 </TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffff99">6,500 </TD><TD style="TEXT-ALIGN: right">26,000 </TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">108</TD><TD style="TEXT-ALIGN: right">21166</TD><TD></TD><TD></TD><TD style="BACKGROUND-COLOR: #ffff99"></TD><TD style="BACKGROUND-COLOR: #ffff99"></TD><TD style="BACKGROUND-COLOR: #ffff99"></TD><TD style="BACKGROUND-COLOR: #ffff99"></TD><TD style="TEXT-ALIGN: right">0 </TD></TR></TBODY></TABLE>

Excel tables to the web >> http://www.excel-jeanie-html.de/index.php?f=1" target="_blank"> Excel Jeanie HTML 4
 
Upvote 0
Just a quick observation ... it looks like ( in row 102 ) that a cell ( or cells ) that was copied contained formulas .... you may want to change your code to copy and then pastespecial values instead of a straight copy. That may fix things.
 
Upvote 0
I am getting an error when I try and add the paste special command to the code. I am sure I didn't put it in the correct place.


Sub multicopy()
' get first file
fname = Dir("g:\accounting\private\msdacct\planning\2011\plan\budgets\budgets reviewed\*.xl*")
Do Until fname = ""
Workbooks.Open (fname)
Sheets("Budget").Select
lastrow = ActiveWorkbook.Sheets(1).Range("B65536").End(xlUp).Row
targetrow = ThisWorkbook.Sheets(1).Range("B65536").End(xlUp).Offset(1).Row
ActiveWorkbook.Sheets(3).Range("B9:H" & lastrow).Copy _
Destination:=ThisWorkbook.Sheets(1).Range("B" & targetrow)
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ThisWorkbook.Sheets(1).Range("A" & targetrow).Resize(lastrow - 9 + 1).Value = _
ActiveWorkbook.Sheets(3).Range("D5").Value
ActiveWorkbook.Close savechanges:=False
fname = Dir
Loop

End Sub
 
Upvote 0
How about:
Code:
Sub multicopy()
' get first file
fname = Dir("g:\accounting\private\msdacct\planning\2011\plan\budgets\budgets reviewed\*.xl*")
Do Until fname = ""
Workbooks.Open (fname)
Set fbook = ActiveWorkbook
Sheets("Budget").Select
lastrow = ActiveWorkbook.Sheets(1).Range("B65536").End(xlUp).Row
targetrow = ThisWorkbook.Sheets(1).Range("B65536").End(xlUp).Offset(1).Row
ActiveWorkbook.Sheets(3).Range("B9:H" & lastrow).Copy 
ThisWorkbook.Activate
Sheets(1).Select
Range("B" & targetrow).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ThisWorkbook.Sheets(1).Range("A" & targetrow).Resize(lastrow - 9 + 1).Value = _
fbook .Sheets(3).Range("D5").Value
fbook.Close savechanges:=False
fname = Dir
Loop

End Sub
 
Upvote 0
Well, I was guessing ... where does it highlight for that error?

Oh I see it .... a space between fbook and .Sheets

Remove that space, and see how it goes.
 
Last edited:
Upvote 0
I am now getting the message, there is a large amount of data on the clipboard.....on every worsheet it pulling in from
 
Upvote 0
You could try emptying the clipboard after the PasteSpecial command. Insert a line of code:
Code:
Application.CutCopyMode = False

If that doesn't work, see if putting
Code:
Application.DisplayAlerts = False
near the top of your code works.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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