Macro to do calculations with sets of data

flanna

New Member
Joined
Jan 30, 2016
Messages
34
Can anyone help with this?
The data is numerical data in a column(columnB). The column receives live data updates so it cannot be sorted in numerical order. ColumnA holds time stamps and must remain in original order All the numbers are between 0.1 and 99.9.
I need to take sets of numbers (i.e. >0 AND <10, >20 AND <=25 etc.) and find SUM, COUNT, STDEV for the last x numbers in each group.
x can be a different value for each group.
I think this can only be achieved with a macro. I am using Excel2016.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi,

With an event macro ... such as Private Sub Worksheet_Change(ByVal Target As Range) you could :

1. If needed, perform an automatic sort ...
2. Refresh all your sum-count-standard deviation formulas ... automatically ...

HTH
 
Upvote 0
Hi,

With an event macro ... such as Private Sub Worksheet_Change(ByVal Target As Range) you could :

1. If needed, perform an automatic sort ...
2. Refresh all your sum-count-standard deviation formulas ... automatically ...

HTH
Thanks James, but what I really need to do is something like this: Find last 20 items from the end of the column where value is more than 5 and less than 10, than using the found items apply various formulas and show results in predefined cell. This has to be repeated each time new data is added to the sheet.
 
Upvote 0
Hi,

There is no contradiction at all ... between your latest message ... and what your event macro can perform ...

If you want to see what event macros are ... https://www.youtube.com/watch?v=ZnnCm7tyqlg

HTH
Yes, an event macro will be the right way to go. But what I really need to know is how to write the rest of the macro. Once I have a working macro it will be easy to make it into an event macro.
 
Upvote 0
I need to take sets of numbers (i.e. >0 AND <10, >20 AND <=25 etc.) and find SUM, COUNT, STDEV for the last x numbers in each group.
x can be a different value for each group.

Back to your first message ... unfortunately all your constraints (input and output) are too vague to write a macro ...

My recommendation would be to turn on your macro recorder and go through one process from start to end ... in order to get a basic structure ...

HTH
 
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,813
Members
449,469
Latest member
Kingwi11y

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