Codeblue
07-05-2012, 06:59 AM
I use this for sorting and wanted to go to the last row
If Columns("C:C").Select Then
Range("C2").Select
ActiveWorkbook.Worksheets("sensitive_data").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("sensitive__3I10Y35OM_data").Sort.SortFields.Add Key _
:=Range("C2"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("sensitive__3I10Y35OM_data").Sort
'.SetRange Range("A2:G1500") ' this worked but limited the range
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
'.Apply ' this caused error when I added the next line of code
End With
Range("A65536").End(xlUp).EntireRow.Delete Shift:=xlUp
End If
If Columns("C:C").Select Then
Range("C2").Select
ActiveWorkbook.Worksheets("sensitive_data").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("sensitive__3I10Y35OM_data").Sort.SortFields.Add Key _
:=Range("C2"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("sensitive__3I10Y35OM_data").Sort
'.SetRange Range("A2:G1500") ' this worked but limited the range
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
'.Apply ' this caused error when I added the next line of code
End With
Range("A65536").End(xlUp).EntireRow.Delete Shift:=xlUp
End If