Results 1 to 4 of 4

Thread: VBA <>VARIABLE Criterial1
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    May 2009
    Location
    Fort Worth, TX
    Posts
    436
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default VBA <>VARIABLE Criterial1

    Need help with autofilter code to show me everything that is not my variable:

    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
    -Steve

    Committed to learning VBA!
    MS Excel 2007 - Windows XP
    MS Excel 2004 - Mac OS X

  2. #2
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    22,856
    Post Thanks / Like
    Mentioned
    383 Post(s)
    Tagged
    41 Thread(s)

    Default Re: VBA <>VARIABLE Criterial1

    Try
    Code:
            .AutoFilter Field:=1, Criteria1:="<>" & cellVal
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 2003 & 2013 on Win 7

  3. #3
    Board Regular
    Join Date
    May 2009
    Location
    Fort Worth, TX
    Posts
    436
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA <>VARIABLE Criterial1

    Works like a champ, Fluff. Thank you so much!!!!

    Quote Originally Posted by Fluff View Post
    Try
    Code:
            .AutoFilter Field:=1, Criteria1:="<>" & cellVal
    -Steve

    Committed to learning VBA!
    MS Excel 2007 - Windows XP
    MS Excel 2004 - Mac OS X

  4. #4
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    22,856
    Post Thanks / Like
    Mentioned
    383 Post(s)
    Tagged
    41 Thread(s)

    Default Re: VBA <>VARIABLE Criterial1

    You're welcome & thanks for the feedback
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 2003 & 2013 on Win 7

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •