+ Reply to Thread
Results 1 to 6 of 6

OFFSET functions are making my macros extremely slow

  1. #1
    Registered User
    Join Date
    12-12-2013
    Location
    China
    MS-Off Ver
    Excel 2010
    Posts
    40

    OFFSET functions are making my macros extremely slow

    Hi all,

    In my workbook I have one sheet that contains a form for data input. This data can be saved with a button which then copies all data into one row on another sheet. Item numbers are shown in the form in a dropdown list which can then load that data back onto the form sheet.

    This was extemely slow and I found out that this was due to 22 offset functions used in the form sheet. They change images based on values in dropdown lists. This problem was solved by changing the value of cell A1 in a hidden sheet when running the macros so that offset is not used. In the name manager I changed all functions to do nothing if that cell contains FALSE. At the end of the macro that loads the information onto the form, I change it back to TRUE which means that offset function can be used again. That was a huge improvement.

    Currently we use many copies of the same workbook to calculate cost for each item (one workbook for one item). Several of these files could be opened for copy pasting into the new file with macros so that they can be saved. The problem is that these older files seem to affect the macros in the new file as well when opened at the same time, and trying to load an item in the new file.

    What I used so far to try to speed up the macro that loads the item:

    Application.EnableEvents = False
    Application.Calculation = xlCalculationManual

    I also started all references to cells and ranges with 'ThisWorkbook'. None of this worked.

    This didn't work. I did try to delete all the images in the form of the external files (without macros) that use the offset function. That did indeed make it a lot faster. Unfortunately, I cannot use the solution above for all of the files as there are way too many.

    If I easily could I would have uploaded a sample file. In this case however, it would take a tremendous amount of work to make one.

    In short, is there any way I can prevent OFFSET functions in other opened excel files to affect the speed of the macros in the file I am working in?

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: OFFSET functions are making my macros extremely slow

    Hi

    If I have understood your explanation correctly, the issue is the linked pictures rather than the OFFSET function itself. That is a known issue and I am not aware of a simple fix for it other than the one you have added to your current workbook.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Registered User
    Join Date
    12-12-2013
    Location
    China
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: OFFSET functions are making my macros extremely slow

    I think it is the offset function.

    Beginning of macro:

    ThisWorkbook.Worksheets("SavedSpecs").Range("A1").Value = False

    In the name manager I changed the functions to: =IF(SavedSpecs!$A$1=TRUE, OFFSET FUNCTION, "")

    Then it worked well. For that reason I thought it is because of the offset functions. Unfortunately there is no way I can modify other files (copies) that might be open at the same time.

    There must be some kind of fix for this?

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: OFFSET functions are making my macros extremely slow

    It is not the function, it's the fact you have a linked picture. It wouldn't matter if it was a direct range reference rather than OFFSET. There is, to the best of my knowledge, no simple workaround for this issue other than the one you are using.

  5. #5
    Registered User
    Join Date
    12-12-2013
    Location
    China
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: OFFSET functions are making my macros extremely slow

    Thanks for your answer. That also explains why I haven't been able to find a solution for this.

    If you have any ideas on how to apply a similar method to other open files (which are copies with other data) that affect the one running the macros, I would happy to hear your suggestion.

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: OFFSET functions are making my macros extremely slow

    You might unlink the pictures temporarily while your code runs (or while your workbook is open) using a routine like this
    Please Login or Register  to view this content.
    so you might then adapt your existing code to look like this
    Please Login or Register  to view this content.
    but you would have to ensure that you didn't accidentally save the other workbooks with the pictures unlinked.

+ 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. Newbie here. Macro functions but extremely slow
    By nkagar2 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-29-2014, 02:43 PM
  2. Extremely Slow code. Please Help
    By flyersguy4 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-30-2011, 09:26 PM
  3. FileCopy extremely slow
    By Idiot in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-07-2008, 12:10 AM
  4. [SOLVED] Extremely slow file
    By Jay in forum Excel General
    Replies: 3
    Last Post: 07-10-2006, 08:19 AM
  5. Workbook is now Extremely Slow
    By Dmorri254 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-03-2005, 02:19 PM
  6. Macros making file saving extremely slow.
    By Donald Speirs in forum Excel General
    Replies: 1
    Last Post: 01-20-2005, 07:06 PM
  7. Macros make file saving extremely slow.
    By Donald Speirs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-20-2005, 02:06 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