+ Reply to Thread
Results 1 to 4 of 4

VBA module code not working after save or cell edit - strange behavior

  1. #1
    Registered User
    Join Date
    02-21-2020
    Location
    USA
    MS-Off Ver
    Premium Plus 2013
    Posts
    2

    VBA module code not working after save or cell edit - strange behavior

    I'm very new to VBA so excuse my ignorance and know that any help is much appreciated.

    I am trying to create a function (in insert>module) to sum based on cell color and then separately (in the sheet1 code) use "Sheets(1).Calculate" to force recalculation of the function. What I thought was going to be a simple tutorial video of about 10 minutes has now turned into 6 hours of hell. The code seems to work at first, but after saving the sheet or making a change to any cell the code stops working and the cell using SumColor does not update unless I double click the cell and press enter.

    Video I was following was "How to SUM Cells by Color in Excel (Get it to update automatically)" by Laila Gharani on YouTube.

    First off, here's what I have:


    (Insert>Module):
    --------------------------------------
    Please Login or Register  to view this content.

    and in (Sheet 1>View Code):
    Please Login or Register  to view this content.

    Is there anything that would cause this to break upon saving the file (as .xlsm) or upon entering/deleting data from ANY cell in the sheet? As you can see in the code, i put some msgbox's in to try and diagnose where it breaks. The msgbox for "sheet" always pops up on selection change, but after saving/modifying cells the "module" msgbox fails to appear. At this point, i try going to Formulas Tab>Calculation>calculate sheet and this does not force recalculation of the cell calling the SumColor function. Should "calculate sheet" do this or is there another way to do it for functions?

    Once my sheet is in this state the only way to make it work again is to go back to the module or sheet code windows and make literally any edit. Add a space, or press enter once or even press space then backspace and its all good until I hit save, etc...

    I just cannot wrap my head around this. Please help.
    Last edited by jpowell1080; 02-21-2020 at 11:30 AM.

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,443

    Re: VBA module code not working after save or cell edit - strange behavior

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    I did it for you this time. Please read forum rules. Thanks

  3. #3
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,443

    Re: VBA module code not working after save or cell edit - strange behavior

    Administrative Note:

    Hi and welcome
    although we value privacy as much as anyone else, it could be important that members have a rough idea of your location. You might in the future post questions which are bound to your regional settings.
    So, please update your profile to something more precise then "Somewhere" ( country will suffice, no need to be more precise).
    Thank you for helping us to help you

  4. #4
    Registered User
    Join Date
    02-21-2020
    Location
    USA
    MS-Off Ver
    Premium Plus 2013
    Posts
    2

    Re: VBA module code not working after save or cell edit - strange behavior

    Thanks for the help. I made the requested changes.

+ 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. vba code to find text string in module and edit it
    By hopefulhart in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-25-2017, 12:05 PM
  2. [SOLVED] Next Assignment Due - Not Working (Strange behavior)
    By delaing in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 10-20-2016, 02:42 PM
  3. [SOLVED] Vba code working in workbook module but not working from personal.xlb
    By satputenandkumar0 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-19-2014, 05:47 AM
  4. Strange behavior from some simple VBA code
    By calibra in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-25-2012, 04:47 PM
  5. Strange TAB behavior
    By m davidson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-28-2006, 01:15 PM
  6. [SOLVED] Cell Entry - Strange Behavior
    By Paige in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-24-2006, 12:20 PM
  7. Save behavior while in Edit/Enter mode
    By RegalTang in forum Excel General
    Replies: 3
    Last Post: 08-19-2005, 04:05 PM

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