+ Reply to Thread
Results 1 to 2 of 2

Quicker VBA

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-23-2004
    Location
    Bristol
    MS-Off Ver
    2016
    Posts
    235

    Quicker VBA

    Hi All, Is there a more efficient way of writing/running the following VBA code? as this code clears the contents from cells across approx 16 sheets. Any help would be greatly appreciated.

    Application.ScreenUpdating = False
            
        Sheets("Access").Range("E12:P12").ClearContents
        Sheets("Access").Range("E14:P14").ClearContents
        Sheets("Access").Range("G21:S28").ClearContents
        
        Sheets("Prefs").Range("M6:V11").ClearContents
        Sheets("Prefs").Range("Q13:V18").ClearContents
        Sheets("Prefs").Range("Q20:V28").ClearContents
        Sheets("Prefs").Range("C31:V39").ClearContents
        Sheets("Prefs").Range("O43:V43").ClearContents
        Sheets("Prefs").Range("C45:V45").ClearContents
        Sheets("Prefs").Range("C47:V47").ClearContents
        Sheets("Prefs").Range("C49:V49").ClearContents
        Sheets("Prefs").Range("C51:V51").ClearContents
        Sheets("Prefs").Range("C53:V53").ClearContents
        Sheets("Prefs").Range("B57:B64").ClearContents
        Sheets("Prefs").Range("E57:V64").ClearContents
        
        Sheets("Ctcts").Range("A2:G1001").ClearContents

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe

     With Sheets("Access")
     .Range("E12:P12,E14:P14,G21:S28").ClearContents
     End With
     With Sheets("Prefs")
     .Range("M6:V11,Q13:V18,Q20:V28,C31:V39,O43:V43,C45:V45,C47:V47,C49:V49,C51:V51,C53:V53,B57:B64,E57:V64").ClearContents
     End With
    With Sheets("Ctcts")
    .Range("A2:G1001").ClearContents
    End with
    Last edited by VBA Noob; 11-10-2007 at 06:53 AM.
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

+ 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