+ Reply to Thread
Results 1 to 7 of 7

Speeding up macros in Excel

  1. #1
    Forum Contributor
    Join Date
    03-14-2005
    Location
    Sweden
    MS-Off Ver
    Office 365
    Posts
    329

    Speeding up macros in Excel

    Hello.

    I have a big problem with the way excel handles my macros. I have created several macros that starts advanced filtering of approximately 9000 rows and 35 columns.

    It takes very long time each time I start one macro. I have disabled the automatic recounting and I have tried to reduce the code as much as possible in the vba editor.

    Do you have any tip on how I can speed excel up even more?

    /Anders

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482
    lets see the code

  3. #3
    Forum Contributor
    Join Date
    03-14-2005
    Location
    Sweden
    MS-Off Ver
    Office 365
    Posts
    329

    Hello Dave.

    I am not able to let you see all code due to its size. It is approximately 70 macros. I give you one example here. Most of the other macros are similar to number one below.

    1: The macro that I have created a button for which run two functions Filter clear inputs and Filter data.

    Sub Filter_Varulager()
    Application.Run "Filter_Clear_inputs"
    Range("C25").Select
    ActiveCell.FormulaR1C1 = "<>1928"
    Range("AP25").Select
    ActiveCell.FormulaR1C1 = "<>H"
    Range("AN25").Select
    Application.Run "FilterData"
    End Sub

    2. Filter Clear Inputs function

    Sub Filter_Clear_inputs()
    Range("A25:IV33").Select
    Selection.ClearContents
    Range("A26").Select
    ActiveCell.FormulaR1C1 = "*"
    Range("A27").Select
    ActiveCell.FormulaR1C1 = "*"
    Range("A28").Select
    ActiveCell.FormulaR1C1 = "*"
    Range("A29").Select
    ActiveCell.FormulaR1C1 = "*"
    Range("A30").Select
    ActiveCell.FormulaR1C1 = "*"
    Range("A31").Select
    ActiveCell.FormulaR1C1 = "*"
    Range("A32").Select
    ActiveCell.FormulaR1C1 = "*"
    Range("A33").Select
    ActiveCell.FormulaR1C1 = "*"
    Range("A25").Select
    Application.Run "FilterData"
    End Sub

    3. Filter data function

    Sub FilterData()
    Range("Databas").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
    Range("FilterCriteria"), Unique:=False
    Range("A24").Select

    End Sub


    Can you see any code that makes it run slowly?

    Thank you.

    /Anders

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482
    You could decrease the amount of times you use select, this would speed up the codes, something like this

    Please Login or Register  to view this content.
    you could use the code
    Application.ScreenUpdating = False
    before a macro to increase the speed as well

  5. #5
    Forum Contributor
    Join Date
    03-14-2005
    Location
    Sweden
    MS-Off Ver
    Office 365
    Posts
    329
    Hello.

    Thank you for your help. Unfortunately it did not speed the whole file up efficient enough.

    What can I do more?

  6. #6
    Forum Contributor
    Join Date
    09-04-2006
    Location
    Yorkshire, England
    Posts
    267

    reply

    Hi

    try the following:

    before macro:

    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    Your code

    At the end of the macro:

    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic

    NOTE: Application.Calculation turns of calculating so it may look like it has crashed as nothing on screen will change untill the end of the macro when it is turned back on


    hope it helps
    JR
    Versions
    Mac OS X 'Leopard'
    Mac MS Office Excel 2004
    Windows XP
    MS Excel 2002
    MS Excel 2003

  7. #7
    Forum Contributor
    Join Date
    03-14-2005
    Location
    Sweden
    MS-Off Ver
    Office 365
    Posts
    329
    What is the difference between having manual calculations turned on in the options menu and the code you have written.

    Does it really speed things up?

    I am confused...:-)

    /Anders

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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