+ Reply to Thread
Results 1 to 12 of 12

Add Last Six Items to Listbox From dynamic range

  1. #1
    Forum Contributor
    Join Date
    12-19-2012
    Location
    Woodbridge, Virginia
    MS-Off Ver
    Excel 2010
    Posts
    111

    Add Last Six Items to Listbox From dynamic range

    All,

    I am trying to build a module to show the user the last 6 recorded invoice transactions they have entered into a table. The dynamic table is comprised of invoices and payments. Currently, the code I have below shows 6 invoices starting from the last 50th invoices due to this code:
    Please Login or Register  to view this content.
    . Of course, this is not what I want the module to do and would like to stay away from the hard count of 50. Can you please let me know how to get it to look from the bottom of the table and pick the last 6 invoices and add them to the listboxes?

    This is what I have so far:

    Please Login or Register  to view this content.
    Thank you in advance for your help!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Add Last Six Items to Listbox From dynamic range

    Perhaps.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    12-19-2012
    Location
    Woodbridge, Virginia
    MS-Off Ver
    Excel 2010
    Posts
    111

    Re: Add Last Six Items to Listbox From dynamic range

    Thank you for the quick reply Norie! I am not sure where to place your line of code. Can you please let me know where I need to stick this in? Sorry about the newbie question. Thank you again!

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Add Last Six Items to Listbox From dynamic range

    Do you need to do this for all the comboboxes/listboxes, eg dateList, locationList etc?

  5. #5
    Forum Contributor
    Join Date
    12-19-2012
    Location
    Woodbridge, Virginia
    MS-Off Ver
    Excel 2010
    Posts
    111

    Re: Add Last Six Items to Listbox From dynamic range

    Yes. Is this how I need to do this? If so, I am getting a Run-Time error: Object doesn't support this property or method.

    Please Login or Register  to view this content.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Add Last Six Items to Listbox From dynamic range

    I think I might have misunderstood what you want.

    The code I posted will be for the last 6 rows not the last 6 invoices.

    Also, I'm not sure why you have multiple listboxes.

    Wouldn't it be better to have one listbox with columns for date, name, location etc?

    If you did then you could populate it like this.
    Please Login or Register  to view this content.
    Would that work for you?

  7. #7
    Forum Contributor
    Join Date
    12-19-2012
    Location
    Woodbridge, Virginia
    MS-Off Ver
    Excel 2010
    Posts
    111

    Re: Add Last Six Items to Listbox From dynamic range

    Wow that looks simple and very clean! Thank you for that. I am getting a Subscript out of range error though. Do you might know why this error is popping up?

    Thank you!!

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Add Last Six Items to Listbox From dynamic range

    Sorry that's my fault, I forgot to exit the loop once 6 invoices had been added to the array.
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    12-19-2012
    Location
    Woodbridge, Virginia
    MS-Off Ver
    Excel 2010
    Posts
    111

    Re: Add Last Six Items to Listbox From dynamic range

    Thank you again Norie. The module opens up without any errors but it seems that the listbox called 1stInvoices is showing null values. Can you please let me know why this could be happening? I have real data in the table and don't know why it isn't showing up with any values.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Add Last Six Items to Listbox From dynamic range

    Can you upload a sample workbook?

  11. #11
    Forum Contributor
    Join Date
    12-19-2012
    Location
    Woodbridge, Virginia
    MS-Off Ver
    Excel 2010
    Posts
    111

    Re: Add Last Six Items to Listbox From dynamic range

    I have to attend a meeting right now and will be back in an hour and a half. I will provide you with a workbook but with dummy data when I return. Thank you for your patience and help!!!!

  12. #12
    Forum Contributor
    Join Date
    12-19-2012
    Location
    Woodbridge, Virginia
    MS-Off Ver
    Excel 2010
    Posts
    111

    Re: Add Last Six Items to Listbox From dynamic range

    Norie, I'm going to mark this as solved. Your code did exactly what I wanted it to do. I messed something up on my end because I was in a rush to get this thing done. But after taking some time and really looking at my code, I got it to finally work! Thank you for your help! Your code did the trick!

+ 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. Transfer random listbox items to new listbox and then loop through selected items
    By narrowgate88 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-31-2013, 05:58 PM
  2. [SOLVED] Find Multi Selected Items in Listbox in Range
    By Sniper in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2012, 07:53 AM
  3. Listbox using a dynamic range name - now not dynamic
    By sarails in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2010, 04:57 AM
  4. selecting multiple listbox items based on test in range
    By kuraitori in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-14-2009, 04:32 PM
  5. [[2003] From specific sheet range into listbox items?
    By jobro in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-24-2008, 05:20 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