+ Reply to Thread
Results 1 to 20 of 20

Macro to Map data columns in two different excel files and produce data in third file

  1. #1
    Registered User
    Join Date
    12-03-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    9

    Macro to Map data columns in two different excel files and produce data in third file

    Hi There

    Would be grateful if someone can help develop a macro to solve below problem

    * Sheet 1 - file 1 is base datafile thats maps our master product file with master product file received from our suppliers / merchants listing supplier product code to our product code, and supplier name to our name. This is prepared basis a one time exercise.

    * Sheet 1 - file 2 is daily price list that we receive from the supplier in that format - it lists down supplier product code, supplier product name, MRP i.e. list price, selling price - at times this is at a discount to list price, and quantity available for sale.

    * Sheet 1 - file 3 is the format in which we need output basis mapping of sheet 1 with sheet 2. Instructions are given against each field. We use file 3 to upload the file in our system that calculates final selling price to retail consumers. Our agents often refer this final file while discussing sales with potential customers.

    the file formats are attached on google drive link here: https://drive.google.com/folderview?...E0&usp=sharing

    Many thanks for your time and help here.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro to Map data columns in two different excel files and produce data in third file

    Hi, welcome to the forum.
    I'll see if I can help. I've downloaded the files and will see if I understood it correctly and let you know.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    12-03-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    9

    Re: Macro to Map data columns in two different excel files and produce data in third file

    Thanks Hans, your help is appreciated.

    Will be happy to clarify as may be needed.

    Regards
    Viral

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro to Map data columns in two different excel files and produce data in third file

    Hi Viral,
    I'm looking into it, but I'll need some time, hope to get something to show you later this evening.
    I understood what you want so it's just implmenting it and writing the code for it.

  5. #5
    Registered User
    Join Date
    12-03-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    9

    Re: Macro to Map data columns in two different excel files and produce data in third file

    Thanks Hans, will look forward to your assistance.

    Regards
    ProMax

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro to Map data columns in two different excel files and produce data in third file

    Today will be difficult, I'll be on a project to whole day.

  7. #7
    Registered User
    Join Date
    12-03-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    9

    Re: Macro to Map data columns in two different excel files and produce data in third file

    I can understand. I can wait for another day too.

    Warm Regards
    ProMax.

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro to Map data columns in two different excel files and produce data in third file

    Hi,
    Based upon what you gave me and the two files you attached.
    Place the attached file in the same folder, open it and press the big button
    A new output file will be created, I only dit Part I to not keep you waiting.
    The filenames are hardcoded but you can change that in the vba code.
    The new output file will be named
    Final_Output-dd-mm-yyyy-HHmm.xlsx (seet attcehd file Final_Output-09-12-2015-1619.xlsx )

    Let me know it this works for you
    Attached Files Attached Files

  9. #9
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro to Map data columns in two different excel files and produce data in third file

    I added the Part II section (not found) and corrected a minor error, should work fine now.
    Attached Files Attached Files

  10. #10
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro to Map data columns in two different excel files and produce data in third file

    Hi Viral,
    I'm just wondering if you are really happy with the offered solution.
    We do this here to help others and share some of the knowledge; just letting know you've seen it would be appreciated

  11. #11
    Registered User
    Join Date
    12-03-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    9

    Re: Macro to Map data columns in two different excel files and produce data in third file

    Dear Hans

    This looks great as a solution - since thanks at the outset. It worked on the sample files we had enclosed. However when we tried on actual file, it failed - note that in actual practice for this one case there were 2100 records in Sheet 1 - mapping file and 7100 records in supplier price information file, the failure was that it returned records as if no records were looked up and hence no data was found at all so all 7100 records were re-populated in the output file. I am attaching data a few records from actual files to see where is the miss. Also, couple of improvements and one point that was not correctly understood - see below:

    A) In the macro file, can we insert three rows to include following information
    • Name of the Merchant. We will enter short names / acronyms and we want that output file bears this name as part of file name
    • Directory path with name of file for Sheet 1 - Promax / Supplier Mapping File
    • Directory path with name of file for sheet 2 - Price Master Received from Supplier - we need this as the supplier will daily send one price information file and the names of the file could differ. We can directly write name as D:/SupplierOne/priceinformation_Dec11.xlsx so that Macro knows that information has to be mapped from this file

    B) The second part of the file for data not found - this needs to be refined further
    We need to populate those records that are there in Sheet 1 but for which no price information was sent by the supplier in sheet 2 and label these records as "Price Information Not Found". I believe currently it is the other way round and populates only those extra records in Sheet 2 for which price information is sent but there is no mapping records Sheet 1 - the base mapping file that maps supplier products to our product masters. In the given example, information is not available only for product code 7546 with name "AASHIR ATTA SEL 5KG" in Sheet two and we will use this output to quickly communicate to supplier that information for this product is missing.


    C) The associate in the company who does this has one more additional request - at times for the same products supplier file has two sets of price information. You can see this in the sample that is culled out from actual file. Can such records - where two or more records of price information is found - can be auto populated as third part under the label "Multiple Price Records found" - we will need validation that the product code first finds place in sheet 1 as those are the only ones where promax is concerned. In given example two price records were found in sheet two for product code 4967 with product name: y-up Drink 600ML. We want to go back to supplier to clarify which is the right price in case multiple price information is sent.

    D) Lasty, the associate also just helped me understand that special price should be blank where MRP / List price equals selling price AND Also where Selling price is only at 1% discount to the MRP/List price. Basically - it was found that to show a discount of only 1% to retail individual customer does not make sense and we rather tell them the MRP/List price.

    I have tried to be as clear as I can, though am always happy to clarify if needed. Many thanks once more for your precious help in framing this solution.

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro to Map data columns in two different excel files and produce data in third file

    Your explanation looks good. What (more) do you expect of me? Write an entire program for you?
    You placed a question on a forum to help you, You got help with what you asked for. Now you've got VBA code to show you how things are done and I'm sure that someone around you with VBA knowledge could build on from there.
    If you want to have someone build an entire application for you than I think you will have to approach another strategy.
    I do this for a living but I also like to help people out with some help and offering ideas; my ideas; my way of approaching the subject. It is not said that my idea is the best. There may be many ways to approach things but I taught myself VBA, took a lot of time an patience and I like it.
    I'll read your mail and and look at your attachments.

  13. #13
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro to Map data columns in two different excel files and produce data in third file

    I suggest you start by attaching a file with the results as you want to have them displayed.
    Your information may be clear to yourself because you work with this every day but to a layman your explanation does not help to see the whole picture.

    Just manually create a sample output file with the information you want to see it displayed, the records with the correct data as well as the missing data

    It is quite normal that you explain something which is very clear to you but the reader does not understand the final picture.

  14. #14
    Registered User
    Join Date
    12-03-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    9

    Re: Macro to Map data columns in two different excel files and produce data in third file

    Thanks, I will prepare sample output file and share soon.

    I had tried approaching people in my local circle to check if someone can help with the problem, before approaching the forum. Unfortunately, could not locate anyone and hence sought help here. I hope you appreciate and my since thanks for your help so far.

    The changes are really not so complex and I am sure with one more attempt, we should get there.

    Thanks a bunch, you have been great help.

  15. #15
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro to Map data columns in two different excel files and produce data in third file

    No problem,
    I'll start on in when you send me the sample output with how you want it done.
    You can do that in one file
    Use Sheet1, Sheet2 and Sheet3

  16. #16
    Registered User
    Join Date
    12-03-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    9

    Re: Macro to Map data columns in two different excel files and produce data in third file

    Dear Hans

    I have enclosed the sample files. I have chosen to do it in separate files so that codes are accordingly written - I am replicating how it happens in reality where all three files are always separate.

    All yellow cells are for instructions only - for reference purposes. These are not available in real life files neither are needed in output files

    I hope this proves useful to you.

    Regards
    Promax

  17. #17
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro to Map data columns in two different excel files and produce data in third file

    I'll download the files and see if I understand it.
    Cheers,

  18. #18
    Registered User
    Join Date
    12-03-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    9

    Re: Macro to Map data columns in two different excel files and produce data in third file

    Sure Hans. Just to iterate, the macro file shared last time had worked perfectly on the sample we had enclosed but when we tried on actual files, it had failed. Not sure if it could be due to size of actual files or some other reasons.

  19. #19
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro to Map data columns in two different excel files and produce data in third file

    If you tel me what went wrong; error message, incorrect results?
    The size should not be a problem, the macro was coded / written based upon what YOU attached so if the definite files are different in layout it will not work anymore.

  20. #20
    Registered User
    Join Date
    12-03-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    9

    Re: Macro to Map data columns in two different excel files and produce data in third file

    Thanks Hans. It was incorrect results. I had check and rechecked the file layouts, they were not different from what I shared originally. I can share again here if needed. Incorrect result can be described as this: The first part it was supposed to generate by mapping sheet 2 data from sheet 1 - was blank. Three rows after that I populated entire records from sheet 2 in the output file as if nothing was every mapped / matched.

    Like I said, it had worked fine on the test files enclosed but it failed on actual files. I can share them if needed [I am new to excel forum, if there is a way to mark this actual files as private, will be useful - so that other audience cannot see actual files]

+ 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: 1
    Last Post: 12-09-2015, 06:20 PM
  2. Replies: 4
    Last Post: 02-12-2014, 06:38 PM
  3. Replies: 4
    Last Post: 05-02-2013, 11:16 AM
  4. Replies: 0
    Last Post: 11-27-2012, 01:43 PM
  5. [SOLVED] I need a macro for copying the data of all excel files into one sheet of a excel file.
    By pavan_yuvaraj in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 10-18-2012, 09:23 AM
  6. Macro for copying specific data from excel files in a folder to a newly created excel file
    By Raju Radhakrishnan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-06-2012, 02:24 PM
  7. Replies: 1
    Last Post: 03-13-2012, 09:45 AM
  8. [SOLVED] Macro copying info/data in multiple excel files into one summary file.
    By Jskasango in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-06-2006, 03:30 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