+ Reply to Thread
Results 1 to 5 of 5

VBA code to add data in the list that meets certain criteria

  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    VBA code to add data in the list that meets certain criteria

    Hi Guys

    I have a Access table that stores BatchNo,Scandate,NewBatchNo . As I can't attach Access database here so I have exported data from Access to Excel in Sheet2 to give you the idea how the data is stored in Access table.

    Now I have to write code in Excel/VBA that will check the last NewBatchNo in the table . In the attached workbook its 194389. Now vba code should check the NewBatchNo which are blank before 194389 . Now in the records where NewBatchNo is blank , it should add the corresponding BatchNo,ScanDate in the listbox1 in userform1.

    e.g Sheet3 in the attached workbook stores Bathcno and Scandate of those records where NewBatchNo is null and before the Last used NewBatchNo which is 194389 in our example.

    ANy help would be much appreciated.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: VBA code to add data in the list that meets certain criteria

    Can anyone please help me in this? I want to check the last used NewBatchNo in the table and then before that NewBatchNo, I have to check the NewBatchNo blank. To all the records where NewBatchNo is blank , add corresponding BatchNo and ScanDate in the listbox using VBA.

    Any help would be much appreciated.
    Thanks

  3. #3
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: VBA code to add data in the list that meets certain criteria

    Run this code on opening you userform (and Listbox), by placing it in the userform module
    Please Login or Register  to view this content.
    Regards Mick

  4. #4
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: VBA code to add data in the list that meets certain criteria

    Thanks Mick. It worked fine. How can I display the column heading BatchNo,ScanDate in the listbox?? Many Thanks

  5. #5
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: VBA code to add data in the list that meets certain criteria

    Try this:-
    NB:- The headers are added in the code, they are not true headers as you can select them, but they will perhaps do !!!
    To add actual Headers you need to set the data as as "RowSource" or "Listfillrange".
    Please Login or Register  to view this content.

+ 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. Replies: 8
    Last Post: 06-25-2014, 01:08 PM
  2. How to generate from larger list a short list that meets multiple criteria
    By ablacksheep in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-28-2014, 09:37 AM
  3. VBA code for last cell that meets certain criteria?
    By shadyferret in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-24-2012, 05:34 PM
  4. How can I extract data from a list that meets certain criteria?
    By fsimek in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-28-2008, 04:20 PM
  5. Adding data in a list that meets a specific criteria
    By Sarah in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-07-2006, 01:35 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