+ Reply to Thread
Results 1 to 3 of 3

Excel 2003: VBA script to colour cell that contains part of text

  1. #1
    Registered User
    Join Date
    10-11-2012
    Location
    Guildford, England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Excel 2003: VBA script to colour cell that contains part of text

    Hi,
    I am trying to identify a script that will enable me to have a cell coloured in, based on that cell containing a text string, or alternatively part of a text string. I can't use conditional formatting as there are 5 possible conditions.

    I have tried to use the Private Sub Worksheet_Change(ByVal Target As Range) script, but I am obviously doing something wrong.

    Attached is a sample, which also include the script.

    To explain; columns D and E will be hidden, but this is where the content for columns A and B will gather their information from. The codes in column D appear as a drop down menu in column A, and column B is populated based on column A, looking up information in column E.

    What I want to happen is that when someone selects a code in the drop down menu on column A, the cell is coloured as per column D.

    I have tested the scrip using numerics, and it works then, however we have a set of codes which are formatted in the same way as the sample, with hyphens etc, so I need to be able to have a script that can work on this type of data.

    I hope this all makes sense, and I hope someone out there can provide me with some help!
    Attached Files Attached Files
    Last edited by garoe; 02-15-2013 at 05:30 AM. Reason: Add attachment

  2. #2
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Excel 2003: VBA script to colour cell that contains part of text

    Hi garoe,

    welcome to the forum.
    There's only a simple mistake in your code, you didn't include a space in the string, so they are not the same. So
    Please Login or Register  to view this content.
    should be
    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Excel 2003: VBA script to colour cell that contains part of text

    Also, consider this solution and feel free to adapt it to your needs.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1