+ Reply to Thread
Results 1 to 8 of 8

How to apply an Index.Match.Match function to all entries in a Listbox on a User Form

  1. #1
    Registered User
    Join Date
    09-18-2018
    Location
    Carthage, NC
    MS-Off Ver
    Office 365 Sudscription
    Posts
    5

    Question How to apply an Index.Match.Match function to all entries in a Listbox on a User Form

    Hello All.

    I am tracking Inspection Items that get accomplished to Aircraft on a spreadsheet with a User Form.
    The User Form is used to pick an Aircraft Tail No., enter flight hours, and landings, also, if an Inspection was accomplished, use Aircraft Tail No., entered flight hours, and landings plus the inspection complied with to enter that information to the aircraft worksheet range. I hope this makes sense, I with try to clarify if you have questions.

    I have a Listbox on the User Form that list all the inspections we do to the aircraft, from this list, the user selects inspection that were complied with and adds them to a second Listbox. I have an Index.Match.Match function that works with a single entry in a Combobox but now I would like to apply this Index.Match.Match function to all the items listed in the second Listbox. Can this be done??

    Can not upload workbook right now, file size to large.
    But here is my code.

    The code below is to add items from lbInsp1 Listbox1 to lbInsp2 Listbox2:

    Please Login or Register  to view this content.
    This code is my Index.Match.Match Function which works from a single entry in a Combobox:

    Please Login or Register  to view this content.
    I am trying to get the workbook file size down so I can upload it, but no promises.

    Thank you much for any help.

    Jason R Drozd
    Last edited by jason.drozd; 09-19-2018 at 11:05 AM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: How to apply an Index.Match.Match function to all entries in a Listbox on a User Form

    Your macro is not a Function. It's just another Sub.

    I'm not sure I follow everything, but you could try something like this (not tested).

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    09-18-2018
    Location
    Carthage, NC
    MS-Off Ver
    Office 365 Sudscription
    Posts
    5

    Re: How to apply an Index.Match.Match function to all entries in a Listbox on a User Form

    AlphaFrog,

    Thank you for getting back with me, I really like that code, seeing that I'm just starting out I didn't think of using a case method (if that is what it is call). But for some reason it didn't work ether. I even tried mod'ing the code but for some reason the entries in the ListBox on my User Form are not going to the sub. I even tried putting it in a variable and doing a For i = 0 to lbInsp2.ListCount - 1 and different If statements after that but before my Call InspUP262:

    Please Login or Register  to view this content.
    The above code is out of my User Form Private Sub cmdUpDate_Click()

    All the code does is stop even without an Error message, so that leads me to believe that the code is good but the data in the ListBox is just not making it to the sub for whatever reason, which is beyond me right now.

    I am going to keep working on this and I guess strip my workbook and code down to one aircraft to see if I can get my workbook under the file limit.

    Thank you much again for your time and thoughts.
    Last edited by jason.drozd; 09-21-2018 at 03:24 PM.

  4. #4
    Registered User
    Join Date
    09-18-2018
    Location
    Carthage, NC
    MS-Off Ver
    Office 365 Sudscription
    Posts
    5

    Re: How to apply an Index.Match.Match function to all entries in a Listbox on a User Form

    Stupid me, I just had to get rid of the pictures I had on my User Form, so here is my workbook:
    Attached Files Attached Files
    Last edited by jason.drozd; 09-21-2018 at 04:04 PM.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: How to apply an Index.Match.Match function to all entries in a Listbox on a User Form

    The code works except this should be D7 and not E7

    Please Login or Register  to view this content.
    This entire line is sort of pointless. It matches the value from cell D7 in row 7. You already know it will match column D. Why use a match function to match the known column? Just use vCol = 3
    Last edited by AlphaFrog; 09-21-2018 at 07:21 PM.

  6. #6
    Registered User
    Join Date
    09-18-2018
    Location
    Carthage, NC
    MS-Off Ver
    Office 365 Sudscription
    Posts
    5

    Re: How to apply an Index.Match.Match function to all entries in a Listbox on a User Form

    AlphaFrog,

    I found where I was screwing up, I still had a reference in my code to a combobox that was empty and I still had the combobox on my form, when I deleted the combobox it through an error that brought my attention to this.
    So with a little more work on my part and with your help and coding I got it working like I want it to and do what I want it to do.

    So thank you very much with this issue.

    As for your reply above: at the time of writing the code I did, it was the only way I could get it to do what I wanted and I stopped there and did not look at code with a select case in it but now with the help you provided me, I am going to do so. I will let you know how it goes.

    Thanks again for the help to get me going on the right track.

  7. #7
    Registered User
    Join Date
    09-18-2018
    Location
    Carthage, NC
    MS-Off Ver
    Office 365 Sudscription
    Posts
    5

    Re: How to apply an Index.Match.Match function to all entries in a Listbox on a User Form

    AlphaFrog,

    Looking further at your code and your question I think it needs one more thing. I will try and explain the process I am trying to do:

    1 - If there is a TailNo in the cbTailNo and a Inspection in lbInsp2 then
    2 - index the range B7:H123, match the Inspection in lbInsp2 to the range B8:B123, then use the value of the cell in column D starting at D7, use this value (DYS, HRS, CYC, or EMMA) to put the correct information in the cell in column E for that inspection

    So I guess in plain English I am saying:

    I need to find the inspection that is in my lbInsp2 listbox on the worksheet for the tailno in cbTailNo in the range B7 to H123,
    when that is done, then I need to find out whether that inspection is HRS, CYC, DYS, or EMMA which is in column D for that inspection,
    with that I need to put the right information in column E for that inspection (HRS = tbHours, CYC = tbCycles, DYS = tbDateTime, EMMA = tbEMMA)

    I hope this explanation makes sense, I sometime have trouble explaining things like this, Let me know?.

  8. #8
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: How to apply an Index.Match.Match function to all entries in a Listbox on a User Form

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 09-25-2018 at 01:56 AM.

+ 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. User defined MATCH-INDEX function in VBA
    By SymMacro in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2016, 05:44 PM
  2. Index/Match to Match entries on multiple criteria
    By manning457 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-06-2015, 02:32 PM
  3. User form with Index Match for 2 input boxes
    By Quasis in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-22-2015, 05:32 PM
  4. [SOLVED] Index & Match Function - Start Looking form RIGHT
    By zeko90 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-10-2015, 03:14 AM
  5. how to apply the function for MATCH and INDEX
    By yjohari in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-31-2013, 09:06 AM
  6. [SOLVED] How to better search with MATCH function in user form?
    By GIS2013 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-29-2013, 08:51 PM
  7. How to write user defined function for Index and Match
    By spybug in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-24-2012, 05:20 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