Hey All,
I'm trying to select the data from column A till P instead of copying, pasting and deleting the whole rows? please see code below and thanks in advance !
I'm trying to select the data from column A till P instead of copying, pasting and deleting the whole rows? please see code below and thanks in advance !
VBA Code:
Sub Sort_Data()
Cells.Select
ActiveWorkbook.Worksheets("ADO").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("ADO").Sort.SortFields.Add(Range("A1:A100"), _
xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = RGB(255, 0 _
, 0)
ActiveWorkbook.Worksheets("ADO").Sort.SortFields.Add(Range("B1:B100"), _
xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = RGB(255, 0 _
, 0)
With ActiveWorkbook.Worksheets("ADO").Sort
.SetRange Range("A1:N100")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
With Sheets("ADO")
If .AutoFilterMode Then .AutoFilterMode = False
.Range("A1:B" & .Range("A" & Rows.Count).End(xlUp).Row).AutoFilter 1, RGB(255, 0, 0), xlFilterCellColor
.AutoFilter.Range.Offset(1).EntireRow.Copy Sheets("TBD_Manually").Range("A" & Rows.Count).End(xlUp)(2)
.AutoFilter.Range.Offset(1).EntireRow.Delete
.ShowAllData
.Range("A1:B" & .Range("B" & Rows.Count).End(xlUp).Row).AutoFilter 2, RGB(255, 0, 0), xlFilterCellColor
.AutoFilter.Range.Offset(1).EntireRow.Copy Sheets("TBD_Manually").Range("A" & Rows.Count).End(xlUp)(2)
.AutoFilter.Range.Offset(1).EntireRow.Delete
.ShowAllData
End With
Range("A2").Select
End Sub