+ Reply to Thread
Results 1 to 4 of 4

VBA Code For AutoFilter

  1. #1
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    VBA Code For AutoFilter

    Hope someone can correct the syntax for me.

    I am creating a text string in VBA that looks like

    fltrtech = "Joe", "Tom", "Bill"

    and then trying to filter a worksheet with

    HTML Code: 
    The list of names are in column X which is 20th column from E.

    If I insert the exact text string in the above command line [in place of variable "fltrtech"] then it works.
    But in my case this text string will change so I need to be able to use a variable.

    Thanks in advance for your help.

    modytrane
    Last edited by modytrane; 04-19-2018 at 11:32 AM.
    1. Click on the * Add Reputation if you think this helped you
    2. Mark your thread as SOLVED when question is resolved

    Modytrane

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,445

    Re: VBA Code For AutoFilter

    Suggest you post all your code and a sample workbook with some typical data so that it can be tested.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: VBA Code For AutoFilter

    I got it to work after doing some research.
    If it helps someone else, I realized that following code works if the variable "fltrtech" is an Array [not just a text string].

    HTML Code: 
    I really appreciate help from all the experts on this forum.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,445

    Re: VBA Code For AutoFilter

    You're welcome.


    Thanks for sharing your solution.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Help With Autofilter VBA Code
    By npsnps in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-26-2016, 12:17 PM
  2. VBA Code - Autofilter and delete
    By Shark Man in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2010, 02:23 AM
  3. Error in VBA Code using AutoFilter
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-21-2010, 01:21 PM
  4. Autofilter in code
    By pavar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-30-2008, 04:35 PM
  5. Autofilter VBA code
    By awbf in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-26-2007, 10:11 AM
  6. Autofilter code
    By Dominic LeVasseur in forum Excel General
    Replies: 2
    Last Post: 08-16-2006, 04:35 PM
  7. selecting an AutoFilter value in code
    By Paul Ponzelli in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-11-2006, 11:35 AM

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.6.0 RC 1