help_questions
Board Regular
- Joined
- Aug 22, 2005
- Messages
- 215
Below is a part of my existing VBA code. It works perfectly. As many of you know at first glance, this code was created using the macro recorder. I want to shorten the code, but not sure how. I know that many of the commands should be done with one command , but i am not experienced enough to understand how/why? Can someone help? Here is the code:
.....
Cells.Select
Cells.EntireColumn.AutoFit
ActiveWindow.SmallScroll ToRight:=7
Columns("K:W").Select
Selection.Delete Shift:=xlToLeft
Columns("AK:CD").Select
Selection.Delete Shift:=xlToLeft
Range("AL:AL,AN:AN,AP:AP,AQ:AQ,AS:AS").Select
Range("AS1").Activate
ActiveWindow.SmallScroll ToRight:=3
Range("AL:AL,AN:AN,AP:AP,AQ:AQ,AS:AS,AU:AU").Select
Range("AU1").Activate
Selection.Delete Shift:=xlToLeft
Range("A1").Select
Range("X:AJ").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select
Range("D5:J5").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
Columns("G:G").Select
Selection.Delete Shift:=xlToLeft
Columns("H:H").Select
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
Range("D5:G5").Select
Range("G5").Activate
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With
.....
Cells.Select
Cells.EntireColumn.AutoFit
ActiveWindow.SmallScroll ToRight:=7
Columns("K:W").Select
Selection.Delete Shift:=xlToLeft
Columns("AK:CD").Select
Selection.Delete Shift:=xlToLeft
Range("AL:AL,AN:AN,AP:AP,AQ:AQ,AS:AS").Select
Range("AS1").Activate
ActiveWindow.SmallScroll ToRight:=3
Range("AL:AL,AN:AN,AP:AP,AQ:AQ,AS:AS,AU:AU").Select
Range("AU1").Activate
Selection.Delete Shift:=xlToLeft
Range("A1").Select
Range("X:AJ").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select
Range("D5:J5").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
Columns("G:G").Select
Selection.Delete Shift:=xlToLeft
Columns("H:H").Select
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
Range("D5:G5").Select
Range("G5").Activate
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With