Getting Cell Values Changing Frequently and Rearranging it in a Compact Manner

maeyks

Board Regular
Joined
Aug 20, 2010
Messages
127
Hello,

I have a table with values and creates a subtotal of each. For example, column A is for fruits, column B is quantity, column C is unit, column D is date.
On the succeeding rows, these are the following:
apple 5 pieces jan 1
apple 6 pieces jan 2
apple 7 pieces jan 3
apple 8 pieces jan 4
and on the next row
Total apple (which is a merged cell from A to C and column D is for the quantity 26 pieces
The next rows are for a different fruit, basically tabulating the same. And showing the subtotal of the next fruit at the end.
what I would like to do is to capture the sub total of each fruits by rows
so i would have
Total apple 26 pieces
Total banana 20 pieces
Total orange 13 pieces

since this will read a dynamic value so the rows for each fruits may vary, it can be 3 rows or even 10 rows depending on the dates

pivot table is not possible since there are merged cells.

so basically I would like to extract the subtotal of each fruits.

hope somebody can assist.

thank you.


michael
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
I am sure there is probably a more elegant way to do this without VBA, but I am a VBA junkie...

I would loop through each row and break them down into sub categories with collections (or list). Have a list for items, then have a list for quantities, both should have matching index numbers. That way, when you call them, you can use something like this:

VBA Code:
Dim N as string
N = Fruits(1)

Dim Q as Long
Q = Quant(1)

Msgbox("Number of " & N & " is " & Q)

Like I said, I am sure there is a more elegant way (and faster as this would take a while to program and execute) but that would be my solution.

It would also help of you could possibly post an example of the data.
 
Upvote 0
I am sure there is probably a more elegant way to do this without VBA, but I am a VBA junkie...

I would loop through each row and break them down into sub categories with collections (or list). Have a list for items, then have a list for quantities, both should have matching index numbers. That way, when you call them, you can use something like this:

VBA Code:
Dim N as string
N = Fruits(1)

Dim Q as Long
Q = Quant(1)

Msgbox("Number of " & N & " is " & Q)

Like I said, I am sure there is a more elegant way (and faster as this would take a while to program and execute) but that would be my solution.

It would also help of you could possibly post an example of the data.
This is a sample work sheet.


I want to capture rows 12, 24 and 36.

Though this can change since if I paste.a new set of records, it may not be on the same rows again. But basically that is the idea, to get the rows for its total.

Thank you.
 
Upvote 0
I was able to compress an image...
Screenshot_2024-03-03-14-49-05-18_99c04817c0de5652397fc8b56c3b3817.jpg
 
Upvote 0
For excel.
OK thanks. In that case I suggest that you update your forum profile (click your user name at the top right of the forum, then ‘Account details’) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Also, it would help if you could provide your small sample data with XL2BB so that helpers can easily copy for testing without having to manually type everything out. :)
 
Upvote 0
OK thanks. In that case I suggest that you update your forum profile (click your user name at the top right of the forum, then ‘Account details’) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Also, it would help if you could provide your small sample data with XL2BB so that helpers can easily copy for testing without having to manually type everything out. :)
Thanks!
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,107
Members
453,021
Latest member
Justyna P

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