+ Reply to Thread
Results 1 to 11 of 11

"Worksheet change" not changing cell on other sheet to match target cell "fill".

  1. #1
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    "Worksheet change" not changing cell on other sheet to match target cell "fill".

    If I change the "fill" on the target cell in Sheet 1, I want the same cell on Sheet 2 to change fill automatically to match.

    Attached file 151002 Match Fill.xlsm shows it works using this Macro on cells E2:

    Please Login or Register  to view this content.
    but doesn't work as this "worksheet change event" using B2 as the target, which is what is actually needed:

    Please Login or Register  to view this content.
    Suggestions, pointers and solutions welcomed as ever

    Ochimus

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: "Worksheet change" not changing cell on other sheet to match target cell "fill".

    Probably:
    Please Login or Register  to view this content.
    is the right way.
    you could also do
    Please Login or Register  to view this content.
    this way it would also react if someone copies say 2 by 2 cells range into A1:B2
    Best Regards,

    Kaper

  3. #3
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: "Worksheet change" not changing cell on other sheet to match target cell "fill".

    Only changing the content of the cell will trigger the Worksheet_Change event, not changing the format.

    You could do it with Selection_Change by holding the address of the selected cell in a static variable, then using that when the next change happens, however that wouldn't work with the cell that is already selected when you open the workbook, so it's not perfect, but that could be trapped with Workbook_Open.

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: "Worksheet change" not changing cell on other sheet to match target cell "fill".

    Thanks Jason for this comment. Thats very true. I focused an opposite condition with checking cell address :-)
    As for Workbook_Open - I'd rater go for Worksheet_Activate for dependant sheet (or may be - for Deactivate for "master" one). It is usually not important what is the color interior of any cell, if a given sheet is not visible.
    Last edited by Kaper; 10-02-2015 at 07:55 AM.

  5. #5
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: "Worksheet change" not changing cell on other sheet to match target cell "fill".

    Will Worksheet_Activate execute when the workbook is opened though?

    My basic line of thought is
    Please Login or Register  to view this content.
    But it needs a way to the activecell to the variable oldTarget before the first selection change is made.

    edit:- If you're thinking of using activate / deactivate to mirror the formatting, then maybe we need some clarification on requirement. That would work with specific ranges, but what if the fill colour was changed on 10 random cells?
    Last edited by jason.b75; 10-02-2015 at 08:33 AM.

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: "Worksheet change" not changing cell on other sheet to match target cell "fill".

    I think that the reqirement is just for limited set of cells. The post is about just one. So in Sheet2 (the "dependant" one) code something like (if the full formatting shall be copied):
    Please Login or Register  to view this content.
    or if it is just about colorindex:
    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Re: "Worksheet change" not changing cell on other sheet to match target cell "fill".

    Appreciate the time everyone is giving to this, but think it's "back to the drawing board", because this short cut isn't working.

    I used one cell as an example in the attachment, but the "real" job has a large stock sheet (100k+ rows and 20 cols), updated regularly against sheet supplied by wholesaler.

    I highlight cells that have changed by "filling" using Conditional Formatting. Which, of course, disappears when I copy the updated cell across, because both sheets now match.

    I was hoping that a "worksheet change" approach would "fill" the relevant cells automatically on the Stock sheet, so they would remain "filled" when I copy the update across.

    As both sheets are the same dimension, I think I'll have to slog through both sheets, and fill and copy cells that don't match.

    I tried the following, but

    Please Login or Register  to view this content.
    Annoying that it should be straightforward.

    Ochimus

  8. #8
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: "Worksheet change" not changing cell on other sheet to match target cell "fill".

    It is and isn't straight forward.

    When you copy formatting from a cell, you copy the actual (permanent) format, not the conditional (temporary) format.

    Could you provide us with a small sample workbook with some fictional data to show what you want done?

  9. #9
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Re: "Worksheet change" not changing cell on other sheet to match target cell "fill".

    Sample file 151001 STOCK CHANGE.xlsm as requested.

    The "FINDDIFFS" Macro highlights cells in the UPDATE sheet that do not match the "CURRENT" sheet.

    The concept was to convert the Conditional Fill into a "hard fill" on either sheet, so the content could then be copied across. The UPDATE sheet can then be discarded ready for the next cycle.

    The sample does not include the second stage of copying the UPDATE content across.

    Hope that clarifies

    Ochimus
    Last edited by Ochimus; 10-02-2015 at 10:59 AM.

  10. #10
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: "Worksheet change" not changing cell on other sheet to match target cell "fill".

    Clear the conditional formatting rules from the sheet, then try this.
    Please Login or Register  to view this content.

  11. #11
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Re: "Worksheet change" not changing cell on other sheet to match target cell "fill".

    jason,

    Thanks to you and everyone else contributing, file now works perfectly.

    Annoying that I've wasted a week trying to solve this.

    Here's to the next challenge. . . .

    Ochimus

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 07-16-2015, 10:14 AM
  2. Replies: 3
    Last Post: 06-05-2015, 01:55 PM
  3. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  4. [SOLVED] Formula Needed to fill multiple cells with "No" when the word "No" is entered into a cell
    By excelteam777 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-09-2013, 05:36 PM
  5. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  6. Change "Parent" cell based on results of multiple "Children" cells
    By ccowman in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 12-14-2012, 02:33 AM
  7. Replies: 3
    Last Post: 02-16-2011, 02:55 PM

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