+ Reply to Thread
Results 1 to 6 of 6

Macro to Change the colour of cell based on text

  1. #1
    Registered User
    Join Date
    04-05-2009
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    44

    Macro to Change the colour of cell based on text

    Hi all,

    I want a macro which can change the colour of cell based on text.

    The selected range has values like -

    1673030
    1673020
    1674020
    1674030

    In the selected range if the fourth charactor is "4" then cell should be coloured in blue, else in red.

    Can anybody help me please.
    Last edited by VBA Noob; 04-25-2009 at 11:52 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro to Change the colour of cell based on text

    You could use the WorkSheet_Change event
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    04-05-2009
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    44

    Thumbs up Re: Macro to Change the colour of cell based on text

    Hi royUK

    the code is not working here.
    Can you please give the complete sub procedure.

    What is WorkSheet_Change event?

    I just want to recolour cell in the selected range. Please help.

    Thanks!

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro to Change the colour of cell based on text

    If you just want a macro to run on a selected range
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-05-2009
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    44

    Thumbs up Re: Macro to Change the colour of cell based on text

    Great thanks!

    But i still dont understand what your original code was?

    Thanks!

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro to Change the colour of cell based on text

    The original code is a sheet event, when a cell is changed the code runs. Try using the xcel VBA help files an explanation.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1