+ Reply to Thread
Results 1 to 12 of 12

Automatic AutoFilter function for optional cells

  1. #1
    Registered User
    Join Date
    03-25-2023
    Location
    Copenhagen
    MS-Off Ver
    Microsoft? Excel? til Microsoft 365 MSO (Version 2301 Build 16.0.16026.20002) 32-bit
    Posts
    11

    Automatic AutoFilter function for optional cells

    Hello

    I am a new member here in this Forum, and I hope there is a friendly member here, who can help me.

    What I'm kindly looking for is probably some VBA code, which unfortunately I don't know much about.

    The attached Excel sample file contains a few accounting entries, where there in column E are some invoice numbers.

    Here I have created a macro (button) that uses the AutoFilter function, to find the data that matches the criterion selected in column E, which in this example is marked with yellow.

    My challenge is, that I have thousands of data rows, where it takes weeks to perform the AutoFilter function manually, to find invoice numbers that have not been paid, etc.

    Therefore, I wish that the criterion (invoice number), which in my sample file is now "statically" inserted into the macro (the yellow cell), could be made selectable. This means that you should be free to select any number and press the button "Filter Selected #" and see the rows where the number is found.

    I hope my explanation makes sense, and that there is a possible solution to my challenge.

    Thank you very much in advance for your reply.
    Attached Files Attached Files

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Automatic AutoFilter function for optional cells

    Hi carmad...
    Welcome to the forum...
    My challenge is, that I have thousands of data rows, where it takes weeks to perform the AutoFilter function manually, to find invoice numbers that have not been paid, etc.
    Attached does what you require...

    However...
    Seems there must be an easier way to get the result you are after...
    I cannot imagine you wanting all the no's stored and then manually selecting and filtering...

    Are you wanting to extract the data or just look at the data?
    What suggests an unpaid invoice?

    Explain in more detail and a simplistic solution can be offered...
    Attached Files Attached Files
    Last edited by sintek; 03-28-2023 at 02:08 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    03-25-2023
    Location
    Copenhagen
    MS-Off Ver
    Microsoft? Excel? til Microsoft 365 MSO (Version 2301 Build 16.0.16026.20002) 32-bit
    Posts
    11

    Re: Automatic AutoFilter function for optional cells

    Hi Sintek

    Wau it was fast, thank you - and the result shows data filtered as I wanted it

    But I can see what you mean, with an easier way compared to "selecting data"...

    In my sample file, I had chosen to show the columns where the AutoFilter is used. But there are also other columns, such as due date, amount, and balance... I hope that's not a problem here, because I thought basically that the AutoFilter function works regardless of how many columns there are in the sheet.

    In principle, I want to see data as it lies in the thousands (not extract), always sorted in date order, where the oldest date is first.

    Now, not every invoice necessarily needs to be checked. So, when I select a particular invoice, it is usually the date I look at where there is doubt in relation to the amount and balance and whether the invoice has been paid.

    Therefore, a "dropdown" list will probably be quite confusing, compared to how far down I look in data. So, there I had thought that I could "select" the cell / invoice number itself, in column B and "press" the "filter button" and thereby get the "automatic AutoFilter function"... Like "get" the "selected" value/cell – maybe?

    I hope that explains the current heavy workflow, which I wish could be made simple with, selecting an arbitrary invoice number down in column B and with a click get the filter data.
    Last edited by carmad; 03-28-2023 at 05:13 AM.

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Automatic AutoFilter function for optional cells

    Therefore, a "dropdown" list will probably be quite confusing, compared to how far down I look in data. So, there I had thought that I could "select" the cell / invoice number itself, in column B and "press" the "filter button" and thereby get the "automatic AutoFilter function".
    So is this the ideal situation for you...

    If so then this is all you need...Select Col B to filter Col 5
    Please Login or Register  to view this content.
    Last edited by sintek; 03-28-2023 at 05:16 AM.

  5. #5
    Registered User
    Join Date
    03-25-2023
    Location
    Copenhagen
    MS-Off Ver
    Microsoft? Excel? til Microsoft 365 MSO (Version 2301 Build 16.0.16026.20002) 32-bit
    Posts
    11

    Re: Automatic AutoFilter function for optional cells

    Thanks for quick reply.

    As mentioned, the choice of the desired filter view will probably not be very clear via a dropdown list.

    It will probably be quite difficult to find an invoice number among thousands compared to how far down in data you stand.

    That is why I fear that we will also lose focus on the task.

  6. #6
    Registered User
    Join Date
    03-25-2023
    Location
    Copenhagen
    MS-Off Ver
    Microsoft? Excel? til Microsoft 365 MSO (Version 2301 Build 16.0.16026.20002) 32-bit
    Posts
    11

    Re: Automatic AutoFilter function for optional cells

    Wau you are fast I can't really keep up. I'll look at what you've done and return ASAP

    Many thanks so far

  7. #7
    Registered User
    Join Date
    03-25-2023
    Location
    Copenhagen
    MS-Off Ver
    Microsoft? Excel? til Microsoft 365 MSO (Version 2301 Build 16.0.16026.20002) 32-bit
    Posts
    11

    Re: Automatic AutoFilter function for optional cells

    Hi again.

    Sorry, I unfortunately don't know where to put your new code

    Have tried in your macro but get: "Compile error: Expected; End of statement.

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Automatic AutoFilter function for optional cells

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    03-25-2023
    Location
    Copenhagen
    MS-Off Ver
    Microsoft? Excel? til Microsoft 365 MSO (Version 2301 Build 16.0.16026.20002) 32-bit
    Posts
    11

    Re: Automatic AutoFilter function for optional cells

    Thank you for your continued help.

    Now I have inserted your code – see screenshot 1.
    For example, when I select E5 and press the "Filter Select" button – see screenshot 2.
    Then the data range disappear from 3 to 11 and I can't scroll any higher ? – see screenshot 3.

    Hope this is a minor thing I can quickly adjust.
    Attached Images Attached Images

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Automatic AutoFilter function for optional cells

    But you said...
    selecting an arbitrary invoice number down in column B and with a click get the filter data.
    If you want to select in Col E and Filter Col E then...
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    03-25-2023
    Location
    Copenhagen
    MS-Off Ver
    Microsoft? Excel? til Microsoft 365 MSO (Version 2301 Build 16.0.16026.20002) 32-bit
    Posts
    11

    Re: Automatic AutoFilter function for optional cells

    Who!

    My mistake, sorry.
    It works perfectly!

    Actually, and precisely because of this error that you corrected, I have really learned a whole lot of important things for me in VBA – thank you so much

    I am very grateful and hope that one day I can also help others. As new in here, in this amazing Forum, what to do now and how can I thank you further?

  12. #12
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Automatic AutoFilter function for optional cells

    Glad to have helped...

+ 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. [SOLVED] Optional Parameter in VBA Function
    By dflak in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-14-2020, 08:04 AM
  2. declaring a function that can take optional parameters
    By mp3909 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-17-2020, 01:56 PM
  3. [SOLVED] Excel VBA Function with optional argument
    By blackgericom in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-06-2016, 12:52 PM
  4. [SOLVED] Optional declared argument is not optional
    By tnuis in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-28-2015, 06:59 AM
  5. [SOLVED] Reading optional parameters in a function
    By TTech925 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2014, 05:53 PM
  6. 2nd. argument (Optional ) in COUNTA() function
    By Rabi in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-13-2007, 08:30 AM
  7. [SOLVED] optional argument in a function
    By visitor in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-13-2005, 03:06 PM

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