VBA <>VARIABLE Criterial1

sachavez

Active Member
Joined
May 22, 2009
Messages
469
Need help with autofilter code to show me everything that is not my variable:

Rich (BB code):
Dim cellVal As String
    Dim cSheet As Worksheet
    Set cSheet = ActiveWorkbook.ActiveSheet
    cellVal = cSheet.Range("A5").Value
   
    
    With ActiveSheet.UsedRange
        .AutoFilter Field:=1, Criteria1:="<> & cellVal &"
        .Offset(1).SpecialCells(xlVisible).EntireRow.Delete
        .AutoFilter
    End With
 

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)
Try
Code:
        .AutoFilter Field:=1, Criteria1:="<>" & cellVal
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,636
Latest member
laura12345

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