+ Reply to Thread
Results 1 to 7 of 7

Filter records using excel 2007 macros not working

  1. #1
    Registered User
    Join Date
    01-19-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    3

    Question Filter records using excel 2007 macros not working

    I had to filter set of records and return the count. I tried recording the steps using macro recorder and wrote this piece of function.

    Please Login or Register  to view this content.
    Not sure what is wrong. Checked the mandatory things like macro security enabled...

    Any help will be appreciated

    Moderators note: code tags added for you - this time
    Last edited by FDibbins; 01-19-2013 at 05:55 PM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Filter records using excel 2007 macros not working

    Ho soundar, and welcome to the forum

    Please note that whe you post VBA code, you are required to use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    I have added them for you this time, please use them next time
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Filter records using excel 2007 macros not working

    Hi soundar.vit

    What is "Chennai"? It's not defined in your code.

    Here's a code snippet to count the visible cells in a Filtered Range
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  4. #4
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    818

    Re: Filter records using excel 2007 macros not working

    Or without filtering.
    Please Login or Register  to view this content.
    Kind regards, Harry.

  5. #5
    Registered User
    Join Date
    01-19-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Filter records using excel 2007 macros not working

    Hi jaslake, thanks for your reply. "Chennai" is the filter parameter. Basically, the macro should do the following.

    1)Select another sheet i.e "Contact Details"
    2) Clear any filter already there in the sheet
    3) Get the range having data
    4) Apply new filter for location i.e "Chennai" and column index = 10
    5) return the resulting row count

  6. #6
    Registered User
    Join Date
    01-19-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Filter records using excel 2007 macros not working

    Hi Harry, Thanks for your time..

    tried ur function too. Getting an error when accessing the object .Columns(10,"Chennai")

    Checked using immediate window
    ?Sheets("Contact Details").UsedRange.Address returns $A$1:$U$92
    But, executing the below snippet throws Run time error 1004- Application -defined or Object defined error
    ?Sheets("Contact Details").UsedRange.Columns(1,10)

  7. #7
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    818

    Re: Filter records using excel 2007 macros not working

    Quote Originally Posted by soundar.vit View Post
    .Columns(10,"Chennai")
    You are missing a closing ")". Copy the code of the forum.
    Or if you are allways looking in columns(10) for "Chennai"?
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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