TechArena Community Excel Added macro for cell color
 User Name Remember Me? Password

#1
19-02-2009
 Member Join Date: Jan 2009 Posts: 303
Excel Added macro for cell color

Hello,

I create a calendar in excel which cells of my days off have a background color red.

I want to assigned a macro to a button on my sheet, through which I add all the red cells that are in 3 different ranges of cells (from A10 to A20 to D10 to D20 and H10 to H20 ) and the result of which is in cell A2.

In the three beaches set all the cells are not red. There are two red cells in the first track, one in the second and three in the third. The number of red cells can change over time. (this is the result of the macro, the result will change according to my additions and deletions of red cells in the three beaches)

The button, I create it but as regards the macro is another kettle of fish.

That is why I appeal to you.

Thank you.
#2
19-02-2009
 Member Join Date: Feb 2008 Posts: 1,848
Re: Excel Added macro for cell color

Test that I do head dc c? that it is possible errors!

Quote:
 int sum, i; sum = 0 for i = 10 to 20 If Range ( "D" & i). font.interior.colorindex = 3 then sum = sum + range ( "D" & i). value end if next i If Range ( "A" & i). font.interior.colorindex = 3 then sum = sum + range ( "A" & i). value end if next i If Range ( "H" & I). font.interior.colorindex = 3 then sum = sum + range ( "H" & I). value end if next i Range ( "A2"). value = sum
#3
19-02-2009
 Member Join Date: Oct 2005 Posts: 2,389
Re: Excel Added macro for cell color

try this hope this will surely work

Quote:
 int sum, i sum = 0 for i = 10 to 20 If Range ( "A" & i). font.interior.colorindex = 3 then sum = sum + range ( "A" & i). value If Range ( "D" & i). font.interior.colorindex = 3 then sum = sum + range ( "D" & i). value If Range ( "H" & i). font.interior.colorindex = 3 then sum = sum + range ( "H" & i). value next i Range ( "A2"). value = sum
#4
19-02-2009
 Member Join Date: May 2008 Posts: 2,293
Re: Excel Added macro for cell color

Small correction

int sum, i is false (C)
Sum , i as integer

 Tags: