VBA Worksheet 'SelectionChange' not working

usnapoleon

Board Regular
Joined
May 22, 2014
Messages
107
Office Version
  1. 365
Platform
  1. Windows
Hello
I have this range of cells that I am working with and I've created modules to calculate the sum within certain text colors. That part works. However if I change the color of cells the sums do not automatically recalculate. I have to go to the formula, 'edit' and hit enter to force a recalculation. I was watching a video to create a VBA that would cause it to automatically recalculate but it's not working.

Here is the range of data:
Plat CC REC- 10 OCT JB.xlsm
EF
5
6
7AmountTransaction
8
9
241
24250S
24350S
24450S
24550S
246143S
247143S
248143S
24949S
25050S
251143S
25250S
25350S
25449S
255143S
256143S
257143S
258143S
2591592
260
2610
262
263Sum Colors
264963
2650
266
OL Activity
Cell Formulas
RangeFormula
F261F261=SUMIF(E248:E259,"Indigo",E247:E259)
F264:F265F264=SumColor(E264,E248:E259)


Here is the programming:
1697669986048.png


Supposedly all I need to do is change the color (column E), and then click outside the cell anywhere on columns A-G and it will cause the recalculation. But its not doing that.

Any help one can give on this? I was watching a tutorial video and I mirrored the process so I'm not sure what is wrong.

Thank you!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Oh, ignore F261... I was messing around, thats not a working formula, I forgot to delete it.
 
Upvote 0
What is the code to get the sum?
 
Upvote 0
Did you make SumColor volatile?
 
Upvote 0
As I understood from a lot of searching on Google, there was not a feature existing in Excel 365 that naturally sums up numbers based on color, so I initially created this VBA Module to define SumColor
1697833655786.png


From there, the excel sheet formula is presented in the original message above in F264
1697833770514.png
 
Upvote 0
As Rory has stated it needs to be volatile
Try putting the code
VBA Code:
Application.Volatile
after the Dim statements
 
Upvote 1
Solution
As Rory has stated it needs to be volatile
Try putting the code
VBA Code:
Application.Volatile
after the Dim statements
That worked!!! Yay!!! Thank you! Sorry for not understanding initially and requiring the exact input to be shown to me...

I am not an Excel expert by any means but I am definitely above average. However, when it comes to VBA ... I'm a total noob. Some parts are familiar to me, such as the if/then statements from when I was working on .lua's, but it's still all Greek. I appreciate you guys. However you got to be as good as you are, it is a blessing to people like myself. Thank you!
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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