+ Reply to Thread
Results 1 to 14 of 14

Automatically Update Data on VBA Code

  1. #1
    Forum Contributor
    Join Date
    08-20-2013
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010, 2016, 2019
    Posts
    110

    Automatically Update Data on VBA Code

    Hi,

    Please advise if it is possible that a VBA code automatically update the data if there is change made?

    I am using the below code to add 38 sheets of data in the same workbook, to 1 sheet (also in the same work book)

    But if I make changes to data on a sheet, the combined sheet, does not update automatically, I have to run the code again

    So I need to know if there is a way that it updates automatically?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Automatically Update Data on VBA Code

    If you only need it to run from 1 particular sheet, change the Sub name to
    Please Login or Register  to view this content.
    and place it in the code window for the sheet you want it to run when a change is made.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Forum Contributor
    Join Date
    08-20-2013
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010, 2016, 2019
    Posts
    110

    Re: Automatically Update Data on VBA Code

    Hi, I need it to take data from 38 different worksheets (in the same workbook), not only 1

  4. #4
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Automatically Update Data on VBA Code

    Will the code you posted do it for the 38 worksheets?

  5. #5
    Forum Contributor
    Join Date
    08-20-2013
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010, 2016, 2019
    Posts
    110

    Re: Automatically Update Data on VBA Code

    The code posted, will combine all 38 sheets into 1 called "combined"

  6. #6
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Automatically Update Data on VBA Code

    k, Try this instead. Change the Sub name to
    Please Login or Register  to view this content.
    and place it with the code in the ThisWorkbook module.
    This will run the code when a change is made to any sheet.

  7. #7
    Forum Contributor
    Join Date
    08-20-2013
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010, 2016, 2019
    Posts
    110

    Re: Automatically Update Data on VBA Code

    Thanks, but I am not sure where you want me to insert it?

  8. #8
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Automatically Update Data on VBA Code

    This will be your code with the new name..
    Please Login or Register  to view this content.
    With the VBA editor window open, on the left side where the Sheet names are listed, you will see one that says ThisWorkbook. Double click on ThisWorkbook and paste the code into the editor window on the right.

  9. #9
    Forum Contributor
    Join Date
    08-20-2013
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010, 2016, 2019
    Posts
    110

    Re: Automatically Update Data on VBA Code

    I did as you said, but it is not doing anything, not even creating the combined tab

    Please see attached a sample of the workbook
    Attached Files Attached Files

  10. #10
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Automatically Update Data on VBA Code

    Is it possible you sent the wrong file? The changes I suggested were not there, but, now that I see what you are working with, I'm not sure my suggestion will work for you. Might be better off creating a button that runs the macro.
    Also, the sample you attached already has a tab named "Combined" therefore it will not create another one named "Combined" because you cannot have 2 sheets with the same name in the same workbook. You may have to add an If statement for the "Combined" sheet...one that says that if the Combined sheet exists then do this else do that.

  11. #11
    Forum Contributor
    Join Date
    08-20-2013
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010, 2016, 2019
    Posts
    110

    Re: Automatically Update Data on VBA Code

    Hi, it is the correct file, and I have already created the tab "combined", all I want the code to do is to update the "combined" tab, if any changes are being made in any of the "wards" tabs

  12. #12
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Automatically Update Data on VBA Code

    Ok, I think I have a better understanding of what you want now. I will modify the code so that it doesn't try to create the combined tab since once is already there.
    I've been tying to think of a way to have the Combined sheet update when the other sheets are changed. I don't think this would be the best approach because the code would run each and every time a change was made to any/all of the sheets which would cause lags and such. I do think I have an idea though. I'm going to place the code in a Worksheet Activate event so that when you click the Combine tab, the code will run then, and only then to update the sheet.
    Edit* Will the Combined sheet always be there????
    Last edited by gmr4evr1; 05-30-2016 at 08:33 PM.

  13. #13
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Automatically Update Data on VBA Code

    If the combined sheet will always be there the slightly modified code in this updated workbook will work..
    Jacolene-automatically-update-data-on-vba-code-sample-copy.xlsm

  14. #14
    Forum Contributor
    Join Date
    08-20-2013
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010, 2016, 2019
    Posts
    110

    Re: Automatically Update Data on VBA Code

    Thank you for your assistance, I will give it a try and let you know

+ 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. [SOLVED] Automatically update cell using VB code
    By biznez in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 05-14-2015, 11:58 AM
  2. VBA Code to automatically update label in the userform
    By sn152 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2014, 06:29 PM
  3. [SOLVED] Update sheet code automatically
    By matrixpom in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-09-2012, 07:06 PM
  4. [SOLVED] Sheet Code To Update Automatically
    By matrixpom in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-15-2012, 09:28 PM
  5. Automatically update existing data using a Update command button
    By 9999335 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-23-2012, 09:46 PM
  6. VBA Code to update links automatically
    By anandvh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-27-2012, 02:49 PM
  7. update VBA code automatically when worksheet changes
    By winamd72 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-30-2008, 06:37 AM

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