+ Reply to Thread
Results 1 to 11 of 11

Apply function on specific rows, based on criteria

  1. #1
    Registered User
    Join Date
    11-18-2013
    Location
    Zurich, Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    54

    Apply function on specific rows, based on criteria

    Hi,

    I would like to apply some functions on SPECIFIC rows of a sheet. Imagine you want to run through 500 rows of another sheet and apply
    a function ONLY for the rows where e.g. Location=UK AND Year=2012. From these rows get the content of a third column (e.g. person)
    and concatenate or sum or min or whatever. I got a little confused with ifs and ranges and I don't know if vlookup can help.

    Thanks

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Apply function on specific rows, based on criteria

    Check Sumifs…

    if possible attach a sample workbook with enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

    Note: Please don't attach documents containing confidential data like (address, telephone, ID#s, etc.).


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    11-18-2013
    Location
    Zurich, Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: Apply function on specific rows, based on criteria

    I uploaded the excel now.

    You can see here what I want. But sumif will work somehow for other functions?
    Last edited by El_engineer; 11-21-2013 at 05:41 AM.

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Apply function on specific rows, based on criteria

    Wow nice picture

    Seems good for my eyes but excel is not allowing me to work with it

  5. #5
    Registered User
    Join Date
    11-18-2013
    Location
    Zurich, Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: Apply function on specific rows, based on criteria

    You don't need to! It's just to get the idea, how do you get the concatenated result from the person column ONLY for
    rows where Location and Year match, and not from all of them?

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Apply function on specific rows, based on criteria

    Without a sample file I can't test and suggest the right solution.

  7. #7
    Registered User
    Join Date
    11-18-2013
    Location
    Zurich, Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: Apply function on specific rows, based on criteria

    Here you are.
    Attached Files Attached Files

  8. #8
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Apply function on specific rows, based on criteria

    Whether duplicate matches cannot be shown in the result?

    Because for UK 2011 the matching results are John;George;Jim;Greg;Greg;John
    But you have shown the expected result as John;George;Jim;Greg

    In which you have shown the john only once.

    Whether the duplicate data should not be shown?

  9. #9
    Registered User
    Join Date
    11-18-2013
    Location
    Zurich, Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: Apply function on specific rows, based on criteria

    I want to show DISTINCT values from the concatenate.
    That means :
    John;George;Jim;Greg for UK, 2011. 4 and not 6 names.

    Thanks

  10. #10
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Apply function on specific rows, based on criteria

    Add the below code in Standard Module of your workbook…

    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    Please Login or Register  to view this content.

    Clookups Range Usage

    =Clookups(LookupValue1, LookupRange1, LookupValue2, LookupRange2,ResultRange,DelimitorText)

    In F3 Cell

    =Clookups(A3,Sheet2!$A$3:$A$15,B3,Sheet2!$B$3:$B$15,Sheet2!$C$3:$C$15,";")

    Drag it down…

  11. #11
    Registered User
    Join Date
    11-18-2013
    Location
    Zurich, Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: Apply function on specific rows, based on criteria

    That was really good! I am starting to use Macros but I haven't gone that far. Seems that you can do
    a lot of things with custom functions. Thank you so much!

+ 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. Hiding Specific Rows Based on a Criteria
    By NeedForExcel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-09-2013, 08:36 AM
  2. Macro to move rows, row by row, based upon specific criteria.
    By luke8182 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-20-2012, 01:05 PM
  3. How can I delete rows based on specific criteria using a macro?
    By akouleze in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-24-2011, 02:49 AM
  4. Delete rows based on specific criteria
    By Archana in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-06-2007, 05:00 AM
  5. [SOLVED] I want to delete certain rows based on specific criteria
    By Alaphas in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-18-2005, 07:06 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