+ Reply to Thread
Results 1 to 9 of 9

Change Active sheet color when data is changed

  1. #1
    Registered User
    Join Date
    02-04-2010
    Location
    North Carolina
    MS-Off Ver
    Excel 2007
    Posts
    52

    Change Active sheet color when data is changed

    Hello all,

    I have a workbook with Several sheets with custom names. What I would like to do is create VBA that when data in the active sheet is changed (A2:A20), it will change the color of the sheet tab to red (255). I need this to work for all the sheets in the workbook. Can you help me out?

    Thanks in advance
    Last edited by usafmeinweg; 02-09-2011 at 03:36 PM.

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Change Active sheet color when data is changed

    see attachment, try to change data in range [a2:a20], changes tab color to red
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    02-04-2010
    Location
    North Carolina
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: Change Active sheet color when data is changed

    watersev,
    That worked like a charm. What if I now want any cell within the worksheet changed (not just A2:A20).

    OR

    I have several worksheets named LastName 3132 and LastName 1098

    Worksheets LastName 3132- if data in cells A2:A20 changes, then sheet color changes to red
    Worksheets LastName 1098- if data in cells D5:D98 cahnges, then sheet color changes to red
    Last edited by usafmeinweg; 02-09-2011 at 11:32 AM.

  4. #4
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Change Active sheet color when data is changed

    see attachament. To see the code (it's very simple): open attachment - Alt+F11 - Ctrl+R - find ThisWorkbook tab under the file name header section and double click it.
    Or open attachment and right-click Excel icon near File menu - Original code - that will take you to the workbook code page.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-04-2010
    Location
    North Carolina
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: Change Active sheet color when data is changed

    On the right track. I have multiple sheets LastName 3132, LastName 1098 "LastName" is variable
    ie.
    Doe 3132, Doe 1098
    Smith 3132, Smith 1098
    (this goes on for about 30 guys)

    In your example, it works only if the sheetname is "LastName 3132". I would like for the code to see that 3132 is in the sheetname and it to apply color to the tab when A2:A20 is changed. And see that 1098 is in the sheetname and it to apply color to the tab when D5:D98 is changed

    I appreciate your help
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Change Active sheet color when data is changed

    in the last attached example colouring works for sheets LastName 3132 and LastName 1098 as per different ranges specified

  7. #7
    Registered User
    Join Date
    02-04-2010
    Location
    North Carolina
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: Change Active sheet color when data is changed

    I got that working, but "LastName 3132" and " LastName 1098" is actually some guys last name ie: Smith 3132, Smith 1098

    There are atleast 30 individuals names. so I don't want to rewrite the code to have
    Please Login or Register  to view this content.
    I would have to do that for all 30+ guys and teach people in my office how to modify the code when they add a new sheet.

    If I can get the code to see that 1098 is in the sheetname then it applies the correct formatting according to the cells that were modified.
    AND
    If the sheet updated contained 3132 in the name, then it would apply that formatting for the other range of values updated.

  8. #8
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Change Active sheet color when data is changed

    if you can create tabs structure with controled range like in this file (1 sheet [a2:a20], 2 sheet [d5:d98], 3 sheet [a2:a20] etc.) then you can add new sheets to the attached book with any names and it will work on them automatically. Otherwise you'll need to name all your sheets in the code as per example
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    02-04-2010
    Location
    North Carolina
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: Change Active sheet color when data is changed

    That worked beautifully. Thank you

+ 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