+ Reply to Thread
Results 1 to 5 of 5

Listbox in userform to populate with all rows containing the Date today AND 2 weeks prior

  1. #1
    Registered User
    Join Date
    11-15-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    41

    Listbox in userform to populate with all rows containing the Date today AND 2 weeks prior

    Hi all!!

    I have a userform with a listbox that populates depending on the date in column 8. Currently the listbox populates only with the rows containing TODAY'S date. I need it to populate with the rows containing today's date and the dates in the 2 weeks before today.

    My current code is as follows:

    Please Login or Register  to view this content.
    I have tried: on the Criteria1 part of my code :
    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.
    But it keeps telling me to debug it..

    Any ideas would be greatly appreciated! Thanks!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,565
    Expand the range you are filtering to include all columns of data.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    11-15-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    41

    Re: Listbox in userform to populate with all rows containing the Date today AND 2 weeks pr

    Sorry, do you mean this bit?
    Please Login or Register  to view this content.
    As I still need it to search this column, I just want it to populate the dates from this column that are today AND within 2 weeks prior to today. Sorry if this was unclear in my explanation, or if I've just completely misunderstood your suggestion, where am I going wrong?

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

    Re: Listbox in userform to populate with all rows containing the Date today AND 2 weeks pr

    You don't just want to populate the listbox with data from that column, you want to populate it from various columns of a larger data set using that column as the filter criteria.

    So expand Range("H4:H" & lastrow) to include all columns in the data set.

    For example if the data extends from column A out to column Q.
    Please Login or Register  to view this content.
    By the way, you could do this without a filter - stick all the data in an array and loop throught it checking the date in column H.

  5. #5
    Registered User
    Join Date
    11-15-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    41

    Re: Listbox in userform to populate with all rows containing the Date today AND 2 weeks pr

    Ahh fab, I stuck it in an array and it works fine now!! Thanks for your help!

+ 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. Hpw to display result if date is prior to today
    By aliceinnz in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-07-2013, 06:58 PM
  2. VBA - Populate Listbox based on value selected in another ListBox (On Userform)
    By raaboo in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-12-2012, 11:18 AM
  3. Auto Email three weeks prior to expiration date of contract?
    By caherine in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-08-2012, 04:29 PM
  4. Populate userform listbox based on value selected in another listbox
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-07-2012, 05:16 PM
  5. Userform ListBox that recalls prior selections made
    By skysurfer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-08-2010, 02:54 PM

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