Autofilter Returns No Results to Set Range

BrittKnee

Board Regular
Joined
Dec 4, 2017
Messages
82
Hi,

Part of a macro I have created filters to a value where it replaces the name of the returned records to something else. I am running into issues where the filter returns no results. I've tried a few different things, but can't get it to work. I'd rather not use On Error. Any help is appreciated. See the code below:

Code:
'Change Name > 31 Characters

    StrOldValue = "Security Business Resource Management"
    StrNewValue = "Security Bus Resource Mgmt"
    
    ActiveSheet.AutoFilter.Range.AutoFilter Field:=2, Criteria1:=StrOldValue


    If Cells(ActiveSheet.AutoFilter.Range.Rows.Count + 1, 1).End(xlUp).Row > 1 Then
        'MsgBox "No records found.", , "No records found"
        'Exit Sub
   

      With ActiveSheet.AutoFilter.Range
        Set RngRange01 = Range("Detail[Department]").SpecialCells(xlCellTypeVisible)
        
        RngRange01.Value = StrNewValue
    
  End With
End If
 
 ActiveSheet.ListObjects(1).AutoFilter.ShowAllData
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,223,886
Messages
6,175,198
Members
452,617
Latest member
Narendra Babu D

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top