+ Reply to Thread
Results 1 to 7 of 7

Speed Help

  1. #1
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    200

    Speed Help

    This is code that is at the end of my macro that takes way too long to accomplish its' necessary purpose. What can I do differently to speed it up? Thanks.


    Sheet9.Select
    ActiveSheet.CheckBoxes.Value = False
    Range("j1.k1").Select
    Selection.ClearContents
    Range("n9.n9").Select
    Selection.ClearContents


    Sheet4.Select
    ActiveSheet.CheckBoxes.Value = False
    Range("j1.k1").Select
    Selection.ClearContents
    Range("n9.n9").Select
    Selection.ClearContents

    Sheet11.Select
    ActiveSheet.CheckBoxes.Value = False
    Range("d1.h1").Select
    ActiveCell.FormulaR1C1 = "Customer Name"
    Range("j1.l1").Select
    ActiveCell.FormulaR1C1 = ""
    Range("o9.o9").Select
    Selection.ClearContents

    Sheet13.Select
    ActiveSheet.CheckBoxes.Value = False
    Range("j1.k1").Select
    Selection.ClearContents
    Range("n9.n9").Select
    Selection.ClearContents


    Sheet15.Select
    ActiveSheet.CheckBoxes.Value = False
    Range("B3.E3").Select
    ActiveCell.FormulaR1C1 = "Customer Name"
    Range("l3.o3").Select
    ActiveCell.FormulaR1C1 = ""
    Range("h11.h11").Select
    Selection.ClearContents


    Sheet22.Select
    ActiveSheet.CheckBoxes.Value = False
    Range("B3.E3").Select
    Selection.ClearContents
    ActiveCell.FormulaR1C1 = "Customer Name"
    Range("h9.j9").Select
    ActiveCell.FormulaR1C1 = ""

    Range("h14.h14").Select
    Selection.ClearContents


    Dim ws1 As Worksheet

    For Each ws1 In Worksheets
    ws1.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, _
    AllowFiltering:=True, Password:="cws"
    Next ws1

    Sheet1.Unprotect Password:="cws"
    Sheet1.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowDeletingRows:=True, AllowInsertingRows:=True, AllowSorting:= _
    True, AllowFormattingCells:=True, Password:="cws"

    Sheet16.Unprotect Password:="cws"
    Sheet16.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowDeletingRows:=True, AllowInsertingRows:=True, AllowSorting:= _
    True, AllowFormattingCells:=True, Password:="cws"


    Sheet1.Select
    Application.ScreenUpdating = True


    End Sub

  2. #2
    Forum Contributor
    Join Date
    01-09-2016
    Location
    Perth Western Australia
    MS-Off Ver
    Office 365
    Posts
    257

    Re: Speed Help

    Hi

    I noticed that your code uses a period between cells in the range reference instead of a colon ( : ). Is this a cause.

    I noticed the application.screenUpdating = Tru reference, Have you also turned calculation to manual at the start of the macro. This may assist in increasing speed.

    Just a thought.

    Cheers

  3. #3
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Speed Help

    Instad of code like this

    Please Login or Register  to view this content.
    avoid "select" and use the commands directly i.e.

    Please Login or Register  to view this content.
    Alf

    Ps After 121 postings you better start following forum rules and wrap you code or you will make the monitors most upset!

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Speed Help

    Precede you code with

    Please Login or Register  to view this content.
    End your code with:-

    Please Login or Register  to view this content.

    This is the subroutine:

    Please Login or Register  to view this content.


    Please Login or Register  to view this content.
    Last edited by mehmetcik; 04-30-2016 at 08:12 AM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  5. #5
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    200

    Re: Speed Help

    When I do this, it gives me a compile error. "Expected End With" & the "end Sub" is highlighted in the macro. ??

  6. #6
    Forum Contributor
    Join Date
    01-09-2016
    Location
    Perth Western Australia
    MS-Off Ver
    Office 365
    Posts
    257

    Re: Speed Help

    Hi

    The block commencing Sheet22 needs an "End with" I think

    Cheers

  7. #7
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    200

    Re: Speed Help

    thx. perfect

+ 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. Everage Speed km/time (european speed)
    By GerryZucca in forum Excel General
    Replies: 3
    Last Post: 02-23-2015, 03:02 PM
  2. [SOLVED] VBA to speed up
    By shiva_reshs in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-16-2014, 12:48 PM
  3. [SOLVED] Speed up if...next VBA
    By olwy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-28-2014, 08:05 AM
  4. Speed up VBA
    By jeroenv in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-14-2013, 08:36 AM
  5. VBA speed up
    By bensonsearch in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-18-2011, 02:46 AM
  6. [SOLVED] How to speed up VBA?
    By Cactus in forum Excel General
    Replies: 3
    Last Post: 06-14-2005, 11:05 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