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

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,224,820
Messages
6,181,154
Members
453,021
Latest member
Justyna P

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