shorter macro

J

jdengel

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"
 
J

JE McGimpsey

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top