Hello,
I am trying to use autofilter criteria to find cells with particular text and based on that trying to fill in cells in Col AC. I have come up with the following code but it is not working the way I expect it to. It runs and insert "RELEVANT TEXT HERE" but not in column AC and also not in the corresponding cells which meets the filter criteria.
I have another code to do the same which loops through each cell but it takes awfully long because my spreadsheet has over 10000 rows. I am hoping to use autofilter to speed up my code.
I am not good with VBA and dont know what am I not doing correctly here. Any help is very much appreciated.
Thanks
I am trying to use autofilter criteria to find cells with particular text and based on that trying to fill in cells in Col AC. I have come up with the following code but it is not working the way I expect it to. It runs and insert "RELEVANT TEXT HERE" but not in column AC and also not in the corresponding cells which meets the filter criteria.
I have another code to do the same which loops through each cell but it takes awfully long because my spreadsheet has over 10000 rows. I am hoping to use autofilter to speed up my code.
I am not good with VBA and dont know what am I not doing correctly here. Any help is very much appreciated.
Thanks
VBA Code:
Sub amt_with_Autofilter()
Dim rng As Range
Dim Report As Worksheet
Dim lr as long
Set Report = ThisWorkbook.Sheets("Report")
lr = Report.Cells(Rows.Count, 4).End(xlUp).Row
With Report
'Firstly, remove the AutoFilter
.AutoFilterMode = False
'Apply the filter
.Range("D8:D" & .Rows.Count).AutoFilter field:=1, Criteria1:="*TESTCASE*"
With .AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then .Range("AC9:AC" & lr).Value = "RELEVANT TEXT HERE"
End With
'Remove the AutoFilter
Report.AutoFilterMode = False
On Error Resume Next
End With
End Sub