Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 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.
Reply With Quote
  #2  
Old 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
Reply With Quote
  #3  
Old 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
Reply With Quote
  #4  
Old 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
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Excel Added macro for cell color"
Thread Thread Starter Forum Replies Last Post
How to change cell color in excel based on text input Chini mao Windows Software 2 06-01-2012 09:19 PM
How to add commas after each text in each cell using Excel Macro Raju Chacha Tips & Tweaks 2 06-01-2012 04:15 PM
Looking for a Excel Macro to delete rows which doesn?t contain a value in particular cell Antariksh Windows Software 6 23-07-2011 01:05 AM
Macro- Excel to copy cell content highlighted Anwar Windows Software 3 06-03-2009 02:04 PM
Excel 2000 - Change Default Cell Fill Color Cris Han MS Office Support 2 20-02-2008 09:29 PM


All times are GMT +5.5. The time now is 01:28 AM.