+ Reply to Thread
Results 1 to 19 of 19

pop up menu with options to select

  1. #1
    Registered User
    Join Date
    07-29-2016
    Location
    london
    MS-Off Ver
    2010
    Posts
    16

    pop up menu with options to select

    Dear All,

    I am trying to create a macro to be with assigned to a button with my little knowledge of VBA, maybe you can give me a hand.
    What I want to do with the macro once I click the button is:

    - open a pop up menu containing a list of options
    - user select one or more options
    - specify a cell where to paste this options
    - close the menu

    Then I am trying to build another macro related to a second button that:

    - open a pop up box
    - select one or more options
    - filter the table and show only rows containing selected words in a specified column.

    Is it something doable or do I have to give up on this ?
    Any help would be HIGHLY appreciated.

    Thanks
    Luca

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: pop up menu with options to select

    See the attachment, for examples of both requirements.

    "Menu 1" opens a form with 3 CheckBox 'options', and a RefEdit control to choose the range to paste the output. Check some options, click OK, and the selected option values are written to the selected cell.

    "Menu 2" opens a form with 3 CheckBox 'options'. Click OK, and the table is filtered to show the selected option values.

    Is this the type of thing you wanted? You can hopefully tweak the forms and the code to suit your actual requirement.

    Here's the code behind the OK buttons:

    Menu1:
    Please Login or Register  to view this content.
    Menu2:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    07-29-2016
    Location
    london
    MS-Off Ver
    2010
    Posts
    16

    Re: pop up menu with options to select

    OLLY THANK YOU SO MUCH !!

    it is definitely the right direction. button 1 is exactly what I wanted. I can select the options I want and the cell where to paste. Button 2 for the filtering is almost there. If I have multiple options in the same cell, the filter will pick up only on those cell with one option selected in the userform. I just want to show any row containing selected options in the userform, whether or not these are one entry only or within multiple entries in the same cell.

    Does this make sense ?

    Thanks A LOT for helping me with this, I spent 3 hours trying to sort it out myself with no success

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: pop up menu with options to select

    That makes sense. Change this line, in the code for the OK button on UserForm2:
    Please Login or Register  to view this content.

  5. #5
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: pop up menu with options to select

    Hmmm. I'm testing that, and it seems yuou can't apply more than TWO filter criteria which contain wildcards...

    Let me research that a bit more, see if I can find a solution.

  6. #6
    Registered User
    Join Date
    07-29-2016
    Location
    london
    MS-Off Ver
    2010
    Posts
    16

    Re: pop up menu with options to select

    hey Ollie, sorry for not gettin back to you sooner.

    Yes, if I try to look for 3 or more 'option' in the column it doesnt show me anything at all.
    Also I am trying to change the code for what I need, I managed to change the options with the services and I tested it in my spreadsheet, first button works fine. The second does not filter as I have multiple columns in my table.
    How do I tell to analyse that specific column containing the key words instead of starting for the first one? The first column is a counter so because the filter looks there, it 'zero's' everything

    Thanks again for your patience !!!!!!!!!!

  7. #7
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: pop up menu with options to select

    Okay, two issues:

    1. You CAN filter on more than two options, but NOT if those options contain wildcards ( *foo* ). So you can filter three (or more) options on exact matches, but only up to two options on partial matches.

    2. To change which field is being filtered, change the number in red:
    Please Login or Register  to view this content.
    This number corresponds to the column number of your filter range, which you want the filter to apply to.

  8. #8
    Registered User
    Join Date
    07-29-2016
    Location
    london
    MS-Off Ver
    2010
    Posts
    16

    Re: pop up menu with options to select

    great, second problem is sorted.

    I just need to bring up the cells (and therefore the row) containing the words I select in the popup box, they are not meant to be combined.
    So if I select Alfa, Bravo, Flower, I want the filter to bring up all the cells containing Alfa,Bravo,Flower in that specific column (that I now know how to define, thanks!!), it doesn't matter if in those cells there are other options or items or whatever u call it as long as the filter picks up the cells containing at least one of the selected words. Not sure I can do that...?

    I am super grateful for this, thanks a lot and sorry if I keep bothering you with all these messages!!!

  9. #9
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: pop up menu with options to select

    As I was trying to explain: With an autofilter, you can have as many EXACT match criteria as you like.

    For example: You could select options 'Alpha', 'Bravo', 'Delta' and 'Hotel' - and the filter would return all cells which exactly match any of those criteria (e.g. "Alpha"). It would NOT return partial matched, however (e.g. "Alpha, Charlie")

    To filter on partial matches, we add the wildcard (e.g. "*Alpha*"), so that all cells containing that pattern are returned in the filter. However, Exel has a limitation on autofilter, where only TWO partial match criteria can be specified.

    So there is no easy solution to your requirement, to filter on more than two partial match criteria. You could potentially write some code to loop through all rows of your data table, checking for partial matches for each criteria, then showing / hiding rows as needed... But this may be very slow indeed, depending on the size of your data table.

  10. #10
    Registered User
    Join Date
    07-29-2016
    Location
    london
    MS-Off Ver
    2010
    Posts
    16

    Re: pop up menu with options to select

    ok ! I will work around that, 2 might be enough
    thanks again, you have been super helpful

  11. #11
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: pop up menu with options to select

    Happy to help.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. You can also 'Add Reputation' to those who have helped you. Thanks.

  12. #12
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: pop up menu with options to select

    Hi,

    There is a workaround for the wildcard problem. You can loop through all the data and create a list of all the actual values that match the criteria and then apply that list to the autofilter. Performance may be a little slow if you have huge volumes of data or numbers of criteria but it is certainly worth testing.

    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  13. #13
    Registered User
    Join Date
    07-29-2016
    Location
    london
    MS-Off Ver
    2010
    Posts
    16

    Re: pop up menu with options to select

    ok I will try this one as well !
    I guess I need to change the number of the column to make sure it looks in the right place..?

    filterData = Sheet1.ListObjects("Table1").DataBodyRange.Columns(1).Value2

  14. #14
    Registered User
    Join Date
    07-29-2016
    Location
    london
    MS-Off Ver
    2010
    Posts
    16

    Re: pop up menu with options to select

    Awesome !! I am just testing it but it seems like working fine with whatever option I pick up !!

  15. #15
    Registered User
    Join Date
    07-29-2016
    Location
    london
    MS-Off Ver
    2010
    Posts
    16

    Re: pop up menu with options to select

    I did make these changes to make sure it was looking at just one column but please correct me if I am wrong..

    filterData = Sheet1.ListObjects("Table1").DataBodyRange.Columns(1).Value2
    ...
    If .Count > 0 Then Sheet1.ListObjects("Table1").Range.AutoFilter Field:=1, Criteria1:=.keys, Operator:=xlFilterValues

    I didnt get any message of error and it seems to filter accordingly to the specified column

  16. #16
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: pop up menu with options to select

    That appears to be the same as the original version so I believe it should be fine.

  17. #17
    Registered User
    Join Date
    07-29-2016
    Location
    london
    MS-Off Ver
    2010
    Posts
    16

    Re: pop up menu with options to select

    yes, it is the same, I just highlighted in red what I changed in my version, name of the sheet, table and column
    But again, I must have changed accordingly and correctly because it works fine, no matter how many options I select, it gives me the rows showing specified words in the pop up window. Thanks a lot you to you both !

  18. #18
    Registered User
    Join Date
    10-09-2019
    Location
    Lisbon
    MS-Off Ver
    2016
    Posts
    1

    Re: pop up menu with options to select

    Hello it is possible to adpat this file in button 2 in order to select not with options but with text through a text box? I need to insert some partial text and then OK and it applies the filter.
    Thanks a lot

  19. #19
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,580

    Re: pop up menu with options to select

    Administrative Note:

    Welcome to the forum Vilna.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread

    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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] Drop down menu, with editable options
    By fallenmathi in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-18-2012, 07:23 PM
  2. Drop Down Menu Options?
    By ibo4lyf in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2008, 12:20 AM
  3. Replies: 3
    Last Post: 07-24-2006, 02:25 PM
  4. Drop-down menu options
    By conksu in forum Excel General
    Replies: 3
    Last Post: 04-27-2006, 02:15 PM
  5. Cannot get into the 'options' menu, any suggestions?
    By Iceman in forum Excel General
    Replies: 2
    Last Post: 03-09-2006, 09:30 PM
  6. Options Menu
    By abarger123 in forum Excel General
    Replies: 5
    Last Post: 08-17-2005, 12:05 PM
  7. Accessing Menu Options from VB Code
    By Zuhair in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-23-2005, 06:05 AM

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