Find Totals and copy them to another worksheet

errtu

Board Regular
Joined
Sep 23, 2010
Messages
134
I will have a table and I'll apply subtotals to it.

I want a macro to find the Commodity Totals and copy those two cells and also the data in the cell to the right and top. Like so:

-------A------------------------B--------------------------C-------
Commodity-----------------#'s-----------------------Price-----
----Cans------------------12------------------------------15.99----
----Cans------------------32------------------------------15.99-----
----Cans------------------78------------------------------15.99----
CANS TOTAL---------122------------------------------ ---------
----Boxes------------------10------------------------------5.99----
----Boxes------------------20------------------------------5.99-----
----Boxes------------------15------------------------------5.99----
BOXES TOTAL---------45------------------------------ ---------

So, the macro should find the total generated by the subtotals button, copy CANS TOTAL, 122 and the value in C4 (15.99) paste it in Worksheet1, then go on and find the next total until it runs out of totals to copy.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Adding subtotals generates an outline ... you can collapse the outline to show only subtotals ... then select only visible cells to copy.
 
Upvote 0
Explain why C4 is to be copied ... do you want the price that is associated with the subtotal to be copied? Are all prices the same for a commodity?
 
Upvote 0
Explain why C4 is to be copied ... do you want the price that is associated with the subtotal to be copied? Are all prices the same for a commodity?

The prices vary for each commodity. Yes, I want the price associated with the subtotal (and that commodity by extension) copied.:)
 
Upvote 0
When you add subtotals, include Price too ... afterwards select the Price column, and do Edit/Replace of (9 to (1 and click the Replace All button. Collapse your outline to show only totals, select the data area, copy, then Paste Special Values whereever you want.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,947
Latest member
Gerry_F

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