Hi. I would like this macro to allow sorting for files with a variable row count. How do I fix the range?
Thanks in advance!
Code:
Sub Proofing()
'
' Proofing Macro
' Arrange columns for the proofing process
'
' Keyboard Shortcut: Ctrl+Shift+W
'
Columns("A:A").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1").Select
ActiveCell.FormulaR1C1 = "Data Check"
Columns("E:E").Select
Selection.Delete Shift:=xlToLeft
Columns("H:J").Select
Selection.Delete Shift:=xlToLeft
Columns("I:L").Select
Selection.Delete Shift:=xlToLeft
Columns("J:T").Select
Selection.Delete Shift:=xlToLeft
Columns("S:S").Select
Selection.Cut
Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Columns("P:T").Select
Selection.Delete Shift:=xlToLeft
Columns("N:O").Select
Selection.Cut
Columns("C:D").Select
ActiveSheet.Paste
Columns("E:E").Select
Selection.Cut
Columns("C:C").Select
Selection.Insert Shift:=xlToRight
Columns("L:L").Select
Selection.Delete Shift:=xlToLeft
Columns("K:L").Select
Selection.Cut
Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Cells.Select
Cells.EntireColumn.AutoFit
ActiveWorkbook.Worksheets("Proofing").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Proofing").Sort.SortFields.Add Key:=Range( _
"B2:B6641"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Proofing").Sort.SortFields.Add Key:=Range( _
"C2:C6641"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Proofing").Sort.SortFields.Add Key:=Range( _
"D2:D6641"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Proofing").Sort.SortFields.Add Key:=Range( _
"F2:F6641"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Proofing").Sort.SortFields.Add Key:=Range( _
"G2:G6641"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Proofing").Sort.SortFields.Add Key:=Range( _
"E2:E6641"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Proofing").Sort
.SetRange Range("A1:AQ6641")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A1").Select
End Sub
Thanks in advance!