+ Reply to Thread
Results 1 to 8 of 8

Import a line of data and then produce a code based on 3 criteria - Read the whole sheet

  1. #1
    Registered User
    Join Date
    11-14-2021
    Location
    Athens
    MS-Off Ver
    365
    Posts
    4

    Post Import a line of data and then produce a code based on 3 criteria - Read the whole sheet

    Hello,

    Recently I have started to learn VBA but it's still difficult for me to solve the following:

    In an excel sheet (monthly orders), each user will import the following data:
    Column A: Month/Year
    Column B: Location (text)
    Column C: Category (text)

    Column D: Here I would like to create a unique code, as follows:
    First, combine the columns A,B,C: "Location/Category/Month" and in the end
    add a letter (with an alphabetical order) of the items that have been imported in the whole excel sheet for the specific month, location & category.
    For example, the format of the unique code (col D) will be:
    Loc1/Cat2/0721/B -> This was the second item for the month July, location1 & category2
    Loc2/Cat2/0721/B -> This was the second item for the month July, location2 & category2

    Your help will be much appreciated!
    Thank you!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Import a line of data and then produce a code based on 3 criteria - Read the whole she

    You can do this using a formula

    D1 = @
    D2 =B2&"/"&C2&"/"&TEXT(A2,"MMYY")&"/"&IF(B2=B1,RIGHT(D1,1), CHAR(CODE(RIGHT(D1,1))+1))

    Fill down.

    Using a Macro

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 11-14-2021 at 05:45 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    11-14-2021
    Location
    Athens
    MS-Off Ver
    365
    Posts
    4

    Re: Import a line of data and then produce a code based on 3 criteria - Read the whole she

    Hello, thank you so much for the quick reply and your help!

    I run the macro and the results are as shown in the excel file I have attached.
    Actually what I need is, every time that a user fills in the columns A,B & C, the macro should read the whole table, count how many items have already been imported for the specific month, location &category, give me the right letter in alphabetical order.
    (The macro code should first read the month then the location and last is the category)

    In column E, I wrote the right results for the unique code I need to produce.

    Thank you in advance!!
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Import a line of data and then produce a code based on 3 criteria - Read the whole she

    Can I sort your data or do you want it kept in that order?

  5. #5
    Registered User
    Join Date
    11-14-2021
    Location
    Athens
    MS-Off Ver
    365
    Posts
    4

    Re: Import a line of data and then produce a code based on 3 criteria - Read the whole she

    Sure! I need to use the filters because there will be more than 30 items per month when the users will start importing their orders.

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Import a line of data and then produce a code based on 3 criteria - Read the whole she

    Kalimera.

    Ok.

    Try this code.

    Please Login or Register  to view this content.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,666

    Re: Import a line of data and then produce a code based on 3 criteria - Read the whole she

    Try
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    11-14-2021
    Location
    Athens
    MS-Off Ver
    365
    Posts
    4

    Re: Import a line of data and then produce a code based on 3 criteria - Read the whole she

    Thank you very much both!! This definitely has helped me a lot.
    Appreciated

+ 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: 2
    Last Post: 08-01-2017, 06:16 AM
  2. [SOLVED] VBA Code to copy different data from one sheet to multiple sheets based on criteria
    By eharwood in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-08-2014, 02:22 PM
  3. Replies: 2
    Last Post: 04-08-2014, 01:01 PM
  4. Just cant get this I need MAster Sheet to produce the field that does not read off
    By detailingking in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-10-2013, 11:34 PM
  5. [SOLVED] Formula to produce list of data based on criteria
    By samcdavies in forum Excel General
    Replies: 7
    Last Post: 06-23-2012, 10:22 AM
  6. [SOLVED] Macro to code the Data set in another sheet to append in columns based on Criteria
    By anchuri_chaitanya in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 06-10-2012, 11:41 AM
  7. VBA code for coping selected data to another sheet based on a criteria
    By BJ5352 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-14-2010, 02:16 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