+ Reply to Thread
Results 1 to 8 of 8

How to recall last selected item in a userform combobox?

  1. #1
    Registered User
    Join Date
    04-14-2012
    Location
    Paris, France
    MS-Off Ver
    Excel 2010
    Posts
    25

    How to recall last selected item in a userform combobox?

    Hello All,

    I've created and coded a vba userform that creates purchase orders for my projects. The user begins by selecting the project code from the combobox (the project code is a unique identifier of each project). Once the purchase order is created, the information is logged in a separate sheet called "POLog" and the userform is cleared. The project code is saved in the first column of the "POLog".

    My problem is that when I have more than one purchase order to create for the same project (sometimes I have 20 or 30), the combobox starts out empty and I have to manually select the project code from the combobox. Is there a way to allow the userform to recall the last project code that was used? Maybe recalling it from the last row in the "POLog" sheet?

    Any help will be greatly appreciated. Thanks!
    Last edited by thedefense; 07-06-2014 at 06:52 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How to recall last selected item in a userform combobox?

    Hello thedefense,

    If you upload a copy of you workbook, we can offer you working solutions. Without the workbook, a lot of time will be wasted guessing.

    Please redact any sensitive or confidential information before you upload the workbook.

    How To Post Your Workbook
    1. At the bottom right of the Reply window, Click the button Go Advanced
    2. At the top of the Your Message Window, in the first row of icons, Click the Paperclip icon.
    3. Click the Add Files button at the top right in the dialog box. This displays the File Manager dialog.
    4. Click the Select Files button at the bottom middle of the dialog.
    5. In the new window Find the file you want to upload, select it, and Click Open.
    6. You will now be back in the File Manager dialog. Click the bottom Middle button Upload File.
    7. Wait until the file has completely uploaded before you exit the File Manager dialog.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: How to recall last selected item in a userform combobox?

    Hello defense,

    It is a bit difficult to give you the correct solution withot seeing what your Code looks like, but you can try adding this line in the appropriate line of your VBA project:

    Please Login or Register  to view this content.
    Regards.
    Last edited by Winon; 07-05-2014 at 01:44 PM. Reason: Corrected Code
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  4. #4
    Registered User
    Join Date
    04-14-2012
    Location
    Paris, France
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: How to recall last selected item in a userform combobox?

    Hello Leith and Winon,

    Thank you for your replies. I've attached the purchase order template. If you click on "create PO" you will see the "Project Code" combobox at the top. This is where I want to have the previously
    selected code to appear which I hope can be recalled from the "PO Log". For example, under "PO LOG" the last project code that was used is "101P - PROJECT 1 - 00 AB"; so if I click on "create PO", I would like to have that code already appearing in the "project code" combobox.

    If you have any other suggestions or comments regarding any of the coding, you're more than welcome to express them.

    Thank you again
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    04-14-2012
    Location
    Paris, France
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: How to recall last selected item in a userform combobox?

    Hello Winon,

    I tried your piece of code but I'm not sure where to insert it. I've tried several places but seems I'm missing something? I've attached the template to make it easier for you. Thank you.

  6. #6
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: How to recall last selected item in a userform combobox?

    Hello thedefense,

    Please try the revised attached Workbook now, and see if it does what you want.

    Regards.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    04-14-2012
    Location
    Paris, France
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: How to recall last selected item in a userform combobox?

    Hello Winon,

    Thank you so much, it works perfectly.

  8. #8
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: How to recall last selected item in a userform combobox?

    Hello thedefense,

    You are welcome, glad I could help.

    Also, thank you for adding to my Reputation.

    Regards.

+ 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. selecting an item in combobox, the item does not get selected
    By AVM in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-14-2014, 05:14 AM
  2. Update Rows in Database based on Combobox selected item on Userform. Problem .
    By jmarriott in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-09-2013, 01:08 PM
  3. Replies: 3
    Last Post: 04-02-2013, 06:02 PM
  4. Combobox: How to determine the location of the selected item if combobox has rowsource
    By ahsanzafar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2012, 03:24 PM
  5. Determine Selected Item in a (Userform’s) ComboBox
    By StevenM in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-07-2012, 09:07 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