Macro to sum totals using resize

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,563
Office Version
  1. 2021
Platform
  1. Windows
I have a macro to sum data from Col C onwards using resize

I get a run time error "Application defined or object-defined error and the code below is highlighted

It would be appreciated if someone could kindly assist me



Code:
 Range("C" & finalrow + 3).Formula = "=sum(C2:C" & finalrow & ").rezize(,7)"

See full code

Code:
 Sub Totals()
Sheets("Data").Select
finalrow = Range("A65536").End(xlUp).Row
Range("B" & finalrow + 3).Value = "Total Value"
Range("C" & finalrow + 3).Formula = "=sum(C2:C" & finalrow & ").resize(,7)"
 
Last edited:

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Resize isn't a worksheet function. Try this...

Code:
Range("C" & finalrow + 3).Formula = "=sum(C2:[COLOR=#ff0000]I[/COLOR]" & finalrow & ")"


If you must use Resize for some reason, try this...

Code:
Range("C" & finalrow + 3).Formula = "=sum(" & Range("C2:C" & finalrow).Resize(, 7).Address & ")"
 
Last edited:
Upvote 0
Hi Howard,

Not sure what you are trying to do but you cannot use .resize in an excel formula.
 
Upvote 0
Thanks for the help

Whst I am trying to achieve using
Code:
Range("C" & finalrow + 3).Formula = "=sum(C2:C" & finalrow & ").resize(,7)"
is to show the totals for each Col seperately using resize or offset

for eg total under C =sum(C2 to the last row in Col C for Col D =sum(D2 to last row in Col D etc instead of using

Code:
 Range("C" & finalrow + 3).Formula = "=sum(C2:C" & finalrow & ")"
Range("D" & finalrow + 3).Formula = "=sum(D2:D" & finalrow & ")" etc for each Col up to Col I


Kindly amend my code
 
Upvote 0
Try

Code:
Range("C" & finalrow + 3).Resize(, 7).Formula = "=SUM(C2:C" & finalrow & ")"

M.
 
Upvote 0
Thanks for the help. Your code works perfectly
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,094
Latest member
teemeren

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