+ Reply to Thread
Results 1 to 13 of 13

Query an Array and list in a User Form

  1. #1
    Forum Contributor
    Join Date
    01-21-2015
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    116

    Query an Array and list in a User Form

    Dear Helpful people!

    I have attached a spread sheet that contains dates in the column and peoples initials underneath. I require a query which is done on a userform that you can input the persons initials.

    It then queries the spreadsheet with only the people initials with a # in front need to copied into the main output on the userform showing the list of dates.

    So in the example if I type AAA in the textbox1 It looks at all dates with #AAA and lists 1/1/2015, 2/1/2015 & 4/1/2015.

    Thank You
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Query an Array and list in a User Form

    I suggest you create a command button on your form then assign this to the button. Type in the search parameter (withholding the #) then click the button. Should populate the listbox

    Please Login or Register  to view this content.
    If you are happy with my response please click the * in the lower left of my post.

  3. #3
    Forum Contributor
    Join Date
    01-21-2015
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    116

    Re: Query an Array and list in a User Form

    Thank you so much that works a treat! This solves a big problem thank you. What I thought would not matter and I am wrong, should have mentioned in my top post. is that most of the initials have numbers at the end.

    For Example:

    #AAA6
    #AAA15

    Some initials are only two characters.

    #BB6

    The current script ignores the leading # how could the following code be modified to ignore the trailing numbers as well.

    Please Login or Register  to view this content.

    Thank you, Rep point on the way.

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Query an Array and list in a User Form

    Change this line

    Please Login or Register  to view this content.
    to this

    Please Login or Register  to view this content.
    That should do the trick.

  5. #5
    Forum Contributor
    Join Date
    01-21-2015
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    116

    Re: Query an Array and list in a User Form

    Thank you again. Yes that does do the trick. Wow that easy when you know how.

    If I could ask one further question. The line

    Please Login or Register  to view this content.
    This sets presumably sets the range from D5 though to NO (999999 or right to the bottom of the sheet)

    If I have two groups of ranges to specifically look in.

    For Example D5 to NO43 and D57 to NO78 how do I alter this line or is there more to it.

    Thank you once again in advance.

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Query an Array and list in a User Form

    Like this:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    01-21-2015
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    116

    Re: Query an Array and list in a User Form

    Thank you again!

    There is one range in which I am required to find an initial that does not have a # in front but has a number at the end

    #AAA6 Do not pass
    AAA6 I do want to pass.

    What do I need to change in your code?

    Please Login or Register  to view this content.
    Many thanks for your help again?!

  8. #8
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Query an Array and list in a User Form

    There is one range in which I am required to find an initial that does not have a # in front but has a number at the end
    I don't think there is a simple solution for this. You will probably have to run multiple loops.

    Can you please elaborate on the parameters which trigger this second search?
    Last edited by stnkynts; 10-21-2015 at 08:28 PM.

  9. #9
    Forum Contributor
    Join Date
    01-21-2015
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    116

    Re: Query an Array and list in a User Form

    Thank you stnkynts

    Another way that would be perfect for us would be to show the complete query cell along side the date in the ListBox.

    So a cell containing either #AAA12 or just AAA12 entered on the date 1/1/2016

    The ListBox would contain. (The two results side by side rather than 2 ListBox's would be preferable)

    1/1/2016 #AAA12

    or

    1/1/2016 AAA12

    Is this easier?

    Your help very much appreciated, thank you.

  10. #10
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Query an Array and list in a User Form

    Is this easier?
    Not at all. Let me do some testing and see what I come up with.

  11. #11
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Query an Array and list in a User Form

    Try this:

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    01-21-2015
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    116

    Re: Query an Array and list in a User Form

    Thank you again. Spot on.

  13. #13
    Forum Contributor
    Join Date
    01-21-2015
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    116

    Re: Query an Array and list in a User Form

    Hi there, one strange thing is since the latest piece of code the date in the ListBox is in American format of MM/DD/YYYY. Is there a quick parameter to change it to DD/MM/YYYY.

    Thank you for your time.

+ 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. Contents of an Array Derived from a macro into a Fixed Display Window, ( User Form ??? )
    By Doc.AElstein in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-05-2015, 08:56 AM
  2. Please help with input form, arrays and a function
    By jbaich in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-20-2014, 01:50 PM
  3. Replies: 4
    Last Post: 11-05-2014, 09:38 AM
  4. [SOLVED] Populating a text area in a user form from an Array???
    By rreifs68 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-17-2013, 08:25 AM
  5. Match new password to specific user and update list via custom user form
    By Sargekd in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-03-2011, 09:40 AM
  6. add list user form, list box and get input
    By rajaneeshjandhyam in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 12-18-2009, 10:57 PM
  7. [SOLVED] Another User Form Query
    By mully in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 05-24-2005, 10:06 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