+ Reply to Thread
Results 1 to 6 of 6

Copy data from raw to template based on 2 conditions

  1. #1
    Forum Contributor
    Join Date
    11-21-2013
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    168

    Copy data from raw to template based on 2 conditions

    Hi all, good day!

    I have monthly raw data of employees in tabular format.
    Total of employees approximately 80 and each of them has a unique ID.

    I am facing difficulties while trying to copy using macro:
    1) My report users are used to a drop down list for selecting the employee that they want to view. However, the template is fixed. Intended result is data auto populated based on selected name from drop down.
    2) I have blank rows ie the targeted range to be copied are not continuous in terms of row
    3) The weekly total (see attached) is consists of Mon to Fri, thus the rows for date is not really fixed as I have to adjust for every begining of month. (In my sample I am assuming dec 1 as monday, i.e. starting day of the week)

    Attached is a sample of my raw and intended result.
    My actual raw and report would be in seperate sheets.

    Appreciate any form of assistance.

    Thank you very much.
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy data from raw to template based on 2 conditions

    Not really a VBA question... INDEX/MATCH makes short work of looking up data in a table using multiple criteria.
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    11-21-2013
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    168

    Re: Copy data from raw to template based on 2 conditions

    hi, thank you for your reply.

    i tried with functions, however, i will have a total of approximately 15000 rows for one month. i already tried using historical data and the file turned out to be very large. i did some experiments and found out that the cause was all the functions that i inserted in the template. i am hoping that i could use vba to minimize the use of function and hence minimizing the file size.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy data from raw to template based on 2 conditions

    You can use VBA (can you?), but the size of the formulas in each cell can be further reduced by using Named Ranges and Named Formulas.

    If I just create a named formula called "MyVal" using the first INDEX/MATCH/MATCH as the base, that's only a few character more per cell than the actual values a macro would enter. Shown in the attached.

    How I did it:

    1) Click on the initial cell (C5), important since the formula is relative and will update itself for each cell we later use it in, so we have to have the correct "base" cell selected when we first create this named formula

    2) Press CTRL-F3 to open the name manager

    3) Create a NEW named formula called MyVal with the same formula that was in the selected cell:
    =INDEX(Data!$D$2:$I$31, MATCH(Report!$B5&Report!$B$2, INDEX(Data!$A$2:$A$31&Data!$C$2:$C$31, 0), 0), MATCH(Report!C$4, Data!$D$1:$I$1, 0))

    4) Close the Name Wizard

    5) Change the formula in C5 to =MyVal

    6) Copy cell around.

    The formula used can also be adjusted to allow for an expanded dataset, or just change the formula to initially use 20k rows or so, whatever you think is sufficient.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    11-21-2013
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    168

    Re: Copy data from raw to template based on 2 conditions

    thank you very much for the effort and enlightenment!

    I will give it a try now.

    Will update should I encounter any difficulties.

    Thank you!

    HC

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy data from raw to template based on 2 conditions

    Please do not use Private Messages for what should be discussed here in the thread. Post a workbook showing your edited formula and data that is not working, we'll see what is wrong.

+ 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. Copy data into a template based on criteria
    By chandrsl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-16-2013, 07:47 PM
  2. Macro for filtering raw data,copy/ pasting and sorting based on conditions
    By amazingjeffery in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-17-2013, 02:45 AM
  3. Replies: 11
    Last Post: 05-12-2013, 11:30 AM
  4. Replies: 0
    Last Post: 12-10-2012, 01:02 PM
  5. Help: Copy/link data from one sheet to another based on conditions
    By norvelle in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-06-2012, 10:21 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