Formula in macro

sujittalukde

Well-known Member
Joined
Jun 2, 2007
Messages
520
I am running a macro which calculated subtotal and total but the GRAND TOTAL is taking the subtotal figure also. So I wnat to set the GRAND TOTAL formula in the macro itself so that GRAND TOTAL comes corrctly?

A picture is attached to clarify the matter.
Book8
ABCD
1A2
2B3
3C4
4AA5
5D6
6E7
7F8
8AA9
9G10
10H11
11I12
12AA13
13GRAND TOTAL63=((SUM(B1:B12))-(SUMIF(A1:B12,"aa",B1:B12)))
14This calculation has to be made in macro
Sheet1


How this can be done?
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
THe macro I have use the sum function. I have made some modification to it so the GRAND TOTAL is changing So I need to change the formula of Grand Total
 
Upvote 0
Perhaps

Code:
Range("B13").Formula = "=SUM(B1:B12)-SUMIF(A1:A12,""aa"",B1:B12)"
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,748
Members
448,989
Latest member
mariah3

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