+ Reply to Thread
Results 1 to 6 of 6

VBA to immediately change the colour of a cell depending on the code placed in another cel

  1. #1
    Registered User
    Join Date
    05-17-2013
    Location
    Glasgow, Scotland
    MS-Off Ver
    MS Office Standard 2013
    Posts
    27

    VBA to immediately change the colour of a cell depending on the code placed in another cel

    Hello,

    Firstly please let me advise that standard conditional formatting will not work here as this requires ten conditions to be set.

    I have a worksheet that contains 40 'paired' columns. In the first column of each pair I can enter any one of ten condition codes. The corresponding cell in the second of the paired columns needs to change its interior colour to that dictated by the code in the first of the pair.

    I have tried a few ways without success with my last attempt almost making it where I used three named ranges and this code:
    Please Login or Register  to view this content.
    Unfortunately this hit the limit on the number of separate columns I could place within one named range and the macro only ran through 4 of the paired columns - even if this had been successful it would still have been unsatisfactory as a macro had to be run to refresh the cells colours. I wish to have the colour change as the code is changed.

    I hope someone in this forum has had a similar requirement in the past and can provide a solution.

    I am using MS Excel 2003 SR3.

    Thanks in anticipation

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA to immediately change the colour of a cell depending on the code placed in another

    I reckon a sample workbook would help-this oughta just be a simple worksheet_change event I think unless there's more to the workbook
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    05-17-2013
    Location
    Glasgow, Scotland
    MS-Off Ver
    MS Office Standard 2013
    Posts
    27

    Re: VBA to immediately change the colour of a cell depending on the code placed in another

    Hello Joseph,
    Please see attached.Paired Columns Worksheet.xls
    Thank you.
    Phil

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: VBA to immediately change the colour of a cell depending on the code placed in another

    Hi Phil.
    I don't get what you're after (conditions2use ??? - data2use ???) but would, like JosephP said, a worksheet_change event with Select Case work?

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA to immediately change the colour of a cell depending on the code placed in another

    right-click the worksheet tab, select 'view code' and then paste in this code
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    05-17-2013
    Location
    Glasgow, Scotland
    MS-Off Ver
    MS Office Standard 2013
    Posts
    27

    Thumbs up Re: VBA to immediately change the colour of a cell depending on the code placed in another

    Hello Joseph,

    Excellent you gave me what I needed.

    Thank you very much.

    Phil

+ 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