VBA <>VARIABLE Criterial1

sachavez

Active Member
Joined
May 22, 2009
Messages
446
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
 

Some videos you may like

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
38,912
Office Version
365
Platform
Windows
Try
Code:
        .AutoFilter Field:=1, Criteria1:="<>" & cellVal
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
38,912
Office Version
365
Platform
Windows
You're welcome & thanks for the feedback
 

Watch MrExcel Video

Forum statistics

Threads
1,096,027
Messages
5,447,939
Members
405,473
Latest member
faworange

This Week's Hot Topics

Top