Closed Thread
Results 1 to 2 of 2

shorter macro

  1. #1
    jdengel
    Guest

    shorter macro

    is there a way to shorten this macro to make it run faster
    thanks
    JD


    Range("C:C,D:D,E:E,F:F,G:G,H:H,I:I").Select
    Range("I1").Activate
    ActiveWindow.SmallScroll ToRight:=6
    Range("C:C,D:D,E:E,F:F,G:G,H:H,I:I,J:P").Select
    Range("J1").Activate
    ActiveWindow.SmallScroll ToRight:=4
    Range("C:C,D:D,E:E,F:F,G:G,H:H,I:I,J:P,Q:Q,R:R,S:S,T:T,U:U").Select
    Range("U1").Activate
    ActiveWindow.SmallScroll ToRight:=7
    Range("C:C,D:D,E:E,F:F,G:G,H:H,I:I,J:P,Q:Q,R:R,S:S,T:T,U:U,V:V,W:W,X:X").Select
    Range("X1").Activate
    ActiveWindow.SmallScroll ToRight:=6
    Range( _
    "C:C,D:D,E:E,F:F,G:G,H:H,I:I,J:P,Q:Q,R:R,S:S,T:T,U:U,V:V,W:W,X:X,Y:Y,Z:Z,AA:AA"
    _
    ).Select
    Range("AA1").Activate
    Selection.ClearContents
    ActiveWindow.SmallScroll ToRight:=-23
    Selection.Delete Shift:=xlToLeft
    ActiveWindow.SmallScroll ToRight:=1
    Range("D:D,G:G").Select
    Range("G1").Activate
    ActiveWindow.SmallScroll ToRight:=5
    Range("D:D,G:G,H:H,J:J,K:K").Select
    Range("K1").Activate
    ActiveWindow.SmallScroll ToRight:=3
    Range("D:D,G:G,H:H,J:J,K:K,L:CI").Select
    Range("L1").Activate
    Selection.ClearContents
    Selection.Delete Shift:=xlToLeft
    Columns("K:K").Select
    ActiveWindow.SmallScroll ToRight:=-3
    Range("I:I,J:J,K:K,L:AE").Select
    Range("L1").Activate
    ActiveWindow.SmallScroll ToRight:=9
    Range("I:I,J:J,K:K,L:AE,AF:AX").Select
    Range("AF1").Activate
    Selection.ClearContents
    Selection.Delete Shift:=xlToLeft
    ActiveWindow.SmallScroll ToRight:=-5
    Columns("F:F").Select
    Columns("A:A").ColumnWidth = 10.57
    Columns("B:B").ColumnWidth = 6.29
    Columns("C:C").ColumnWidth = 32.57
    Columns("E:E").ColumnWidth = 15
    Selection.ColumnWidth = 7.57
    Columns("G:G").ColumnWidth = 12.57
    Columns("H:H").ColumnWidth = 10.86
    Selection.AutoFilter
    Range("B2").Select
    Selection.AutoFilter
    Selection.AutoFilter
    Selection.AutoFilter Field:=2, Criteria1:="TRUE"



  2. #2
    JE McGimpsey
    Guest

    Re: shorter macro

    One way:

    Dim vWidths As Variant
    Dim i As Long
    Application.ScreenUpdating = False
    Range("C:AA,AC:AC,AF:AG,AI:DH,DK:EZ").Delete Shift:=xlToLeft
    vWidths = Array(10.57, 6.29, 32.57, 15, 7.57, 12.57, 10.86)
    For i = 1 To UBound(vWidths)
    Columns(i).ColumnWidth = vWidths(i)
    Next i
    Range("B2").AutoFilter Field:=2, Criteria1:="TRUE"
    Application.ScreenUpdating = True

    Note that you almost never need to select anything. Using the range
    objects directly (i.e., Range("C:AA...").Delete) is faster, shorter,
    and, IMO, easier to maintain.


    In article <[email protected]>,
    "jdengel" <[email protected]> wrote:

    > is there a way to shorten this macro to make it run faster


Closed 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