Change cell value based on current open sheet

  • Hi!


    I was wondering if it is possible to change the value of a cell based on the currently active worksheet of another workbook?


    I have 2 workbooks, Book1.xlsm (macro enabled workbook) and Book2.xlsx (normal workbook), opened simultaneously.


    If the currently active worksheet in Book2.xlsx is Sheet1, the value of Cell A1 in Sheet1 of Book1.xlsm should be 1.
    If the currently active worksheet in Book2.xlsx is Sheet2, the value of Cell A1 in Sheet1 of Book1.xlsm should be 2.


    Finally, I want to run a macro based on whenever this cell value changes. One could run it based on Current Active Sheet Cell value change, but the problem is that the cell where the value is changing is not on the currently active sheet.


    Thanks,


    Naira.

  • Re: Change cell value based on current open sheet


    Easily...


    Add the following to the ThisWorkBook class module



    You then need something to choose a workbook to monitor from those loaded...


    Perhaps a userform with a combobox (named 'cbo'), Style set to DropDownList, and 2 buttons (cmdOK & cmdCancel). cmdOK is not enabled by default.


    Following code in userform


    Does not include the 'Finally...' - that was added while I was posting.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!