+ Reply to Thread
Results 1 to 4 of 4

Dynamic Autofilter range format

  1. #1
    Forum Contributor
    Join Date
    02-15-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    141

    Dynamic Autofilter range format

    Hi, Guys,

    This should be a pretty quick/simple question. I recorded the following macro that adds an autofilter, sets a criteria, and sorts. I would just like to generalize the code and make it dynamic, because the number of rows may sometimes increase.

    Could someone show me the proper format?

    Please Login or Register  to view this content.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Dynamic Autofilter range format

    Hi, kestefon,

    if the data is limited by an empty column as well as an empty row you could use Range("A2").CurrentRegion for that. Untested:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    02-15-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    141

    Re: Dynamic Autofilter range format

    Thanks, Holger. That's what I'm looking for. By the way, I'm getting an "object required" error message for this part of the code...any ideas?

    Please Login or Register  to view this content.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Dynamic Autofilter range format

    Hi, kestefon,

    certainly because the code hadnīt been tested before (neither is this). Try
    Please Login or Register  to view this content.
    as to the macro code the line belongs to the Sheet rather than the Range object.

    Ciao,
    Holger

+ Reply to Thread

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