+ Reply to Thread
Results 1 to 6 of 6

Populate Field(s) with Unique Value From Separate File

  1. #1
    Registered User
    Join Date
    10-28-2013
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2013
    Posts
    8

    Populate Field(s) with Unique Value From Separate File

    Hello All,
    I have a file of 40,000 unique codes that need to be assigned to customer records, dependent on the quantity of items they purchased. For every pair of items the customer purchased, they are entitled to 1 unique code (so, 6 items purchased, 3 unique codes assigned). These codes need to be deleted from the source list so that they can't be mistakenly reassigned. The customer records file contains NAME, CODE1, CODE2, (etc, up to CODE6), and ITEM QUANTITY. I could put IF statements in each of the CODE# fields that will look at the ITEM QUANTITY field, and copy a value if TRUE, however, I'm not sure how to go about making sure that code is a unique one from the source list. Is it possible to use a CUT/COPY function?

    Hope this is clear enough.

    Thanks in advance!

  2. #2
    Valued Forum Contributor
    Join Date
    09-25-2011
    Location
    Eastbourne, England
    MS-Off Ver
    Excel 2010
    Posts
    1,089

    Re: Populate Field(s) with Unique Value From Separate File

    Hi a68tbird

    I'm not clear about how a code will be applied to a pair of items and not clear how a code will be put to 1 of 6 CODE columns. Other than that, it all seems quite straight forward.

    Perhaps if you were to supply a sample of what you have it might make things more obvious?

    Regards
    Alastair

  3. #3
    Registered User
    Join Date
    10-28-2013
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Populate Field(s) with Unique Value From Separate File

    Thanks Alastair,
    I have attached two sample files: one is a list of unique codes, the other the customer records file. Each record shows the quantity of the item the customer purchased. For every two items purchased, they receive 1 unique code. So, Customer1, purchased 2 items. CODE1 (at B2) needs a value from the CODES file. Customer4 purchased 5 items, so they are entitled to 2 codes - one in B5, one in C5.

    As these codes are assigned, they must not be used again. So each time a code is pulled from the CODES file, it must be a new, unused value.

    Hope this helps!
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    09-25-2011
    Location
    Eastbourne, England
    MS-Off Ver
    Excel 2010
    Posts
    1,089

    Re: Populate Field(s) with Unique Value From Separate File

    Hi a68tbird

    I think that the attached CustomerRecords.xlsm (note not ".xlsx") will do what you want.

    You will need to have your Codes.xlsx file open.

    To run the macro press Ctrl+shift+Q and to see the code press Alt+F8 / step into.

    I have not deleted the codes when used - just marked them (it makes testing much easier !).

    Let me know if this is what you want.

    Regards
    Alastair
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-28-2013
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Populate Field(s) with Unique Value From Separate File

    Wow! Thanks very much Alastair. This works perfectly. Very much appreciated!

  6. #6
    Valued Forum Contributor
    Join Date
    09-25-2011
    Location
    Eastbourne, England
    MS-Off Ver
    Excel 2010
    Posts
    1,089

    Re: Populate Field(s) with Unique Value From Separate File

    You're welcome. Glad to have been of assistance

    Regards
    Alastair

+ 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. Manipulating data in a separate Excel file to populate another?
    By reach78 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-09-2013, 08:48 PM
  2. Pulling text from a separate .cvs file to populate a cell.
    By ihatekale in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-08-2013, 05:43 PM
  3. Replies: 1
    Last Post: 04-25-2013, 05:07 PM
  4. Replies: 3
    Last Post: 08-11-2009, 09:45 AM
  5. populate unique entries to txt file
    By ymeyaw in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-16-2006, 08:15 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