+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    06-08-2009
    Location
    Wolverhamptpn, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Macro- Custom Filter Containing

    Guys,

    I'm trying to write a macro that will custom filter a column for cells containing the value in a cell, the macro I have so far is:

    Sub Filter()

    ActiveSheet.AutoFilterMode = off
    LookupVal = Range("C3")
    Range("A8").AutoFilter Field:=4, Criterial:=LookupVal

    End Sub

    However that only returns cells that are equal to C3, normally to do contains I would put "* *" around the value but then that removes the reference to cell C3, any ideas how to combine the two?
    Last edited by Stuart2; 06-09-2009 at 09:30 AM.

  2. #2
    Forum Guru
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2003
    Posts
    1,227

    Re: Macro- Custom Filter Containing

    Try with this code:
    Code:
    Sub Filter()
       ActiveSheet.AutoFilterMode = off
       LookupVal = Range("C3")
       Range("A8").AutoFilter Field:=4, Criterial:="=*" & LookupVal & "*"
    End Sub
    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    06-08-2009
    Location
    Wolverhamptpn, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Macro- Custom Filter Containing

    Works brilliantly, thanks so much.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0