VBA <>VARIABLE Criterial1
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
    26,858
    Post Thanks / Like
    Mentioned
    459 Post(s)
    Tagged
    45 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 365 on Win 10

  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
    26,858
    Post Thanks / Like
    Mentioned
    459 Post(s)
    Tagged
    45 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 365 on Win 10

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
  •