Results 1 to 4 of 4

Thread: Excel Added macro for cell color

  1. #1
    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. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Excel Added macro for cell color

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

    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. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Excel Added macro for cell color

    try this hope this will surely work

    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. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: Excel Added macro for cell color

    Small correction

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

Similar Threads

  1. How to change cell color in excel based on text input
    By Chini mao in forum Windows Software
    Replies: 2
    Last Post: 06-01-2012, 09:19 PM
  2. Replies: 2
    Last Post: 06-01-2012, 04:15 PM
  3. Replies: 6
    Last Post: 23-07-2011, 01:05 AM
  4. Macro- Excel to copy cell content highlighted
    By Anwar in forum Windows Software
    Replies: 3
    Last Post: 06-03-2009, 02:04 PM
  5. Excel 2000 - Change Default Cell Fill Color
    By Cris Han in forum MS Office Support
    Replies: 2
    Last Post: 20-02-2008, 09:29 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,530,876.82858 seconds with 16 queries