+ Reply to Thread
Results 1 to 20 of 20

Create formula that can fetch the data on criteria

  1. #1
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Create formula that can fetch the data on criteria

    Hello
    I have a report that indicates the lectures that the student "A" had.
    I want to create a vba or formula that can fetch the data on criteria "Student Name"
    The data sheet may extend to 1000 column and more than 100 students
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Create formula that can fetch the data on criteria

    In C5, enter this array formula with Ctrl + Shift + Enter keys together and drag + fill the formula from C5 to G5.
    =INDEX(Data!$C$3:$M$28,MATCH(Report!$E$1,Students,0),MATCH(C3&C4,Data!$C$1:$M$1&Data!$C$2:$M$2,0))

  3. #3
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Create formula that can fetch the data on criteria

    Quote Originally Posted by JieJenn View Post
    In C5, enter this array formula with Ctrl + Shift + Enter keys together and drag + fill the formula from C5 to G5.
    =INDEX(Data!$C$3:$M$28,MATCH(Report!$E$1,Students,0),MATCH(C3&C4,Data!$C$1:$M$1&Data!$C$2:$M$2,0))
    Thank you Mr JieJenn But Iwant 3 formulas not one:
    1- formula to fetch the lecturer
    2-formula to fetch the lectures
    3-formula to fetch dates
    Your formula needs to be edited :
    I don`t want the dates formula to depend on the lecturer and lectures data
    Thanks
    Last edited by leprince2007; 12-02-2016 at 04:19 PM.

  4. #4
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Create formula that can fetch the data on criteria

    Keep the array formula just extend the range. Anyway, give this code a try.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Create formula that can fetch the data on criteria

    First,your code isn`t complete because it doesn`t fetch "date field"
    Secondly: I want to do the job using formulas.

  6. #6
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Create formula that can fetch the data on criteria

    My knowledge in Excel is insufficient, hopefully someone else will be able to assist you.

  7. #7
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Create formula that can fetch the data on criteria

    Can you complete your code to fetch date field also??

  8. #8
    Registered User
    Join Date
    12-02-2016
    Location
    Poland
    MS-Off Ver
    2007
    Posts
    16

    Re: Create formula that can fetch the data on criteria

    Hi leprince, try maybe an array formula (to C3):
    Please Login or Register  to view this content.
    One Formula is it enough... I think... Best regards...

  9. #9
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Create formula that can fetch the data on criteria

    Quote Originally Posted by hurgadion View Post
    Hi leprince, try maybe an array formula (to C3):
    Please Login or Register  to view this content.
    One Formula is it enough... I think... Best regards...
    Thank you sir
    But I need 3 formulas as I mentioned before:
    1- formula to fetch the lecturer
    2-formula to fetch the lectures
    3-formula to fetch dates
    Thank you again

  10. #10
    Registered User
    Join Date
    12-02-2016
    Location
    Poland
    MS-Off Ver
    2007
    Posts
    16

    Re: Create formula that can fetch the data on criteria

    One Formula is it enough... drag and fill this formula (from C3 to G5)... You have Three Formulas in One...

  11. #11
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Create formula that can fetch the data on criteria

    When I change student name to"C" or any other name,I found the formula didn`t fetch date field.
    Please note that my data sheet may expand to 1000 column and more than 100 students.
    Last edited by leprince2007; 12-02-2016 at 06:29 PM.

  12. #12
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Create formula that can fetch the data on criteria

    1- formula to fetch the lecturer
    2-formula to fetch the lectures
    3-formula to fetch dates
    While I suppose one could argue that the below formulas for Lecturer and Lectures are the same formula with different INDEX 1st arguments it works because the layout of the data permits it.

    Try array entering this in C3. Then fill down and across to G4. If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Then array enter this in C5 and fill across.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Will this work?
    Dave

  13. #13
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Create formula that can fetch the data on criteria

    Thanks I will try it and let you know

  14. #14
    Registered User
    Join Date
    12-02-2016
    Location
    Poland
    MS-Off Ver
    2007
    Posts
    16

    Re: Create formula that can fetch the data on criteria

    You have to change my Solution or the Solution of FR, if You have more Columns as in the above Example...

    Don't forget to enter this array formula with Ctrl+Shift+Enter...

    PS. I like Hurgada...
    Last edited by hurgadion; 12-02-2016 at 07:04 PM.

  15. #15
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Create formula that can fetch the data on criteria

    Your solution is great,but I replaced:
    Please Login or Register  to view this content.
    with this
    Please Login or Register  to view this content.
    and I replaced also :
    Please Login or Register  to view this content.
    with this:
    Please Login or Register  to view this content.
    and I did that in order to simplify the formulas and their results are correct.Is it ok???
    Waiting your feedback

  16. #16
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Create formula that can fetch the data on criteria

    Quote Originally Posted by leprince2007 View Post
    Your solution is great,but I replaced:
    Please Login or Register  to view this content.
    with this
    Please Login or Register  to view this content.
    and I replaced also :
    Please Login or Register  to view this content.
    with this:
    Please Login or Register  to view this content.
    and I did that in order to simplify the formulas and their results are correct.Is it ok???
    Waiting your feedback
    up....up......up

  17. #17
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Create formula that can fetch the data on criteria

    Can anyone create a vba code because I tried formulas but they slow down my pc?????

  18. #18
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Create formula that can fetch the data on criteria

    leprince2007,

    I did this part

    COLUMN($C:$M)-MIN(COLUMN($C:$M))+1 to allow flexibility. Should you insert / deleted columns to the left of the formula this "resets" the first column number to 1 and does it without need for editing. That shouldn't slow the workbook. The same is true of COLUMNS($C:C).

    The likely culprit in the slow down are the whole column references such as in MATCH(Report!$E$1,Data!$B:$B,0).


    Try replacing the formulas in post #12 with these. They are still array entered. In C3 then filled down and across to G4
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Then array enter this in C5 and fill across.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    The reason for selecting row 1000 is to make adequate room for additional rows.

    If 1000 is not enough edit the formulas to include a little more than what you would anticipate. ie if anticipated need is 500 make it 750 or more. The main thing to avoid with exact matches is referencing whole columns.

    My apologies for the oversight.

  19. #19
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Create formula that can fetch the data on criteria

    Thank you sir well done

  20. #20
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Create formula that can fetch the data on criteria

    You are welcome. Thank you for the feedback and the rep.

+ 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: 5
    Last Post: 04-12-2016, 11:30 PM
  2. [SOLVED] Need Macro/Formula to Fetch the data from table
    By gunjan8882 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-16-2016, 08:12 AM
  3. Replies: 12
    Last Post: 12-20-2013, 10:04 AM
  4. based on a selection criteria fetch matching rows
    By shruthitulsi in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-11-2011, 11:09 AM
  5. Replies: 1
    Last Post: 12-22-2010, 09:08 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