This code works the issue I have is it takes a very long time for it to execute due to the large data. If I were to do this manually then I would apply my filter criteria then go to column F select the first cell of filtered data then control shift down then drag that selection over the Column G. The data changes daily so one day the filtered data may begin in cell F1590 next day may be F1580 etc. Any advice would be appreciated.
Sub Scrubbing()
Dim LastRow As Long
Dim FilteredDataRange As Range
Dim Cell As Range
' Disable screen updating to improve performance
Application.ScreenUpdating = False
' Find the last row in column A (assuming it contains the data)
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
' Apply the filter criteria to column AB (Field 24)
ActiveSheet.Range("$A$1:$AB$" & LastRow).AutoFilter Field:=24, Criteria1:="=No", Operator:=xlOr, Criteria2:="="
' Apply the filter criteria to column G (Field 7)
ActiveSheet.Range("$A$1:$AB$" & LastRow).AutoFilter Field:=7, Criteria1:=Array( _
"ALL SUPERVISORS", "IN-PLANT SUPPORT", "MAIN DISTRIBUTION TOUR-I", _
"MAIN DISTRIBUTION TOUR-II", "MAIN DISTRIBUTION TOUR-III", _
"MAINTENANCE OPERATIONS"), Operator:=xlFilterValues
' Find the first cell with filtered data in column F (excluding header)
Set FilteredDataRange = Columns("F").SpecialCells(xlCellTypeVisible)
If Not FilteredDataRange Is Nothing Then
' Loop through each visible cell in column F
For Each Cell In FilteredDataRange
' Fill right in column G for the current cell in column F
Cell.Offset(0, 1).Resize(1, Cell.MergeArea.Cells.Count).Value = Cell.Value
Next Cell
End If
' Clear the filters
ActiveSheet.AutoFilterMode = False
' Re-enable screen updating
Application.ScreenUpdating = True
End Sub
[/CODE]
Sub Scrubbing()
Dim LastRow As Long
Dim FilteredDataRange As Range
Dim Cell As Range
' Disable screen updating to improve performance
Application.ScreenUpdating = False
' Find the last row in column A (assuming it contains the data)
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
' Apply the filter criteria to column AB (Field 24)
ActiveSheet.Range("$A$1:$AB$" & LastRow).AutoFilter Field:=24, Criteria1:="=No", Operator:=xlOr, Criteria2:="="
' Apply the filter criteria to column G (Field 7)
ActiveSheet.Range("$A$1:$AB$" & LastRow).AutoFilter Field:=7, Criteria1:=Array( _
"ALL SUPERVISORS", "IN-PLANT SUPPORT", "MAIN DISTRIBUTION TOUR-I", _
"MAIN DISTRIBUTION TOUR-II", "MAIN DISTRIBUTION TOUR-III", _
"MAINTENANCE OPERATIONS"), Operator:=xlFilterValues
' Find the first cell with filtered data in column F (excluding header)
Set FilteredDataRange = Columns("F").SpecialCells(xlCellTypeVisible)
If Not FilteredDataRange Is Nothing Then
' Loop through each visible cell in column F
For Each Cell In FilteredDataRange
' Fill right in column G for the current cell in column F
Cell.Offset(0, 1).Resize(1, Cell.MergeArea.Cells.Count).Value = Cell.Value
Next Cell
End If
' Clear the filters
ActiveSheet.AutoFilterMode = False
' Re-enable screen updating
Application.ScreenUpdating = True
End Sub
[/CODE]