Results 1 to 4 of 4

Thread: Excel Cell Font Color Programatically

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046

    Excel Cell Font Color Programatically

    I have a spreadsheet with some cells black and some red. Im trying to programatically tell the difference in a macro, but cells(x,y).Font.Color is equal to 0 for all cells whether red or black. Is there another prop to look at?

    Thanks in advance for any help!

  2. #2
    Addicted Member malik641's Avatar
    Join Date
    Sep 2005
    Location
    South Florida :-)
    Posts
    221

    Re: Excel Cell Font Color Programatically

    Cells(x,y).Font.Color returns 255 for red for me, and 0 for black.

    When you deal with the Color property, it returns an RGB color code that you can split apart using a method found on Chip Pearson's site. Check it out, it's a good read (the one I'm talking about is 3/4 toward the bottom under "RGB Colors").

    You can also use Font.ColorIndex which returns a number from the color palette.

    HTH
    Last edited by malik641; Nov 15th, 2007 at 11:16 AM.




    If you find any of my posts of good help, please rate it

  3. #3
    Lively Member
    Join Date
    Jun 2008
    Location
    Philippines
    Posts
    70

    Re: Excel Cell Font Color Programatically

    How about changing the back color ? and aligning the text. THANKS

  4. #4
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: Excel Cell Font Color Programatically

    Quote Originally Posted by Muddy
    I have a spreadsheet with some cells black and some red. Im trying to programatically tell the difference in a macro, but cells(x,y).Font.Color is equal to 0 for all cells whether red or black. Is there another prop to look at?

    Thanks in advance for any help!
    When you say "some cells black and some red" do you mean the background color of the cells and not the foreground color?

    Use .Color or .ColorIndex for foreground (or text) color
    Use .Interior.Color or .Interior.ColorIndex for background color.
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width