+ Reply to Thread
Results 1 to 13 of 13

Searching for a value in multiple sheets

  1. #1
    Registered User
    Join Date
    02-22-2013
    Location
    Rajahmundry
    MS-Off Ver
    Excel 2010
    Posts
    18

    Searching for a value in multiple sheets

    Sir,

    In the attached file which consists of multiple sheets, column 'K' contains chemical compound names. I have to search for the same compound name exists in this worksheet and in different worksheets (i.e., comparing value in 'K1' cell with all the cell values in that column i.e., K2....Kn). If it is found in the same worksheet or in different worksheets, it has to be highlighted. This process is to be repeated for all cell values in column 'K'. (i.e., compare value in 'K2' with all cell values in column 'K' in the same worksheet and in different work sheets). I attached a partial part of the file but it is a big file. I tried with VLOOKUP and failed to get it as I am a research scholar in chemistry.
    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: Searching for a value in multiple sheets

    I would have to recommend you employee VBA for this.

    Here's a simple User Defined Function (UDF) I created to do this easily for you. The function is used in the workbook like so:

    =CountInSheets(CellwithString, ColumnNumber)

    For instance: =CountInSheets(K1, 11)
    This tells you how many times the value in K1 appears in column 11 in all sheets in the workbook. Here's the code:
    Please Login or Register  to view this content.

    How to install the User Defined Function:

    1. Open up your workbook
    2. Get into VB Editor (Press Alt+F11)
    3. Insert a new module (Insert > Module)
    4. Copy and Paste in your code (given above)
    5. Get out of VBA (Press Alt+Q)
    6. Save as a macro-enabled workbook

    The function is installed and ready to use.
    ===============

    Now, since you want the duplicated cells to be "highlighted", I would use this new function as a Conditional Formatting formula.

    1) Highlight all the sheets.
    2) Highlight column K
    3) Create a conditional formatting rule in that column with the color of your choosing and the formula:
    =CountInSheets(K1, 11)>1

    Now, all the items that appear in more than one place will highlight the color you selected. Here's your workbook back with that installed and working.
    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 Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Searching for a value in multiple sheets

    Thanks for the feedback. If that takes care of your original query, please select Thread Tools from the menu above and mark the thread as solved. Thanks.

  4. #4
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Searching for a value in multiple sheets

    Dove si trova la risposta?


    Edit: Translation: Where is the feed back?
    Last edited by Fotis1991; 02-25-2013 at 06:05 AM. Reason: Edit
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  5. #5
    Registered User
    Join Date
    02-22-2013
    Location
    Rajahmundry
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Searching for a value in multiple sheets

    I could not find the answer with the code as "CountInSheets(K1,11)>1"

  6. #6
    Registered User
    Join Date
    02-22-2013
    Location
    Rajahmundry
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Searching for a value in multiple sheets

    I am unable to find the answer with the code as "CountInSheets(K1,11)>1". Help me

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

    Re: Searching for a value in multiple sheets

    Click GO ADVANCED and use the paperclip icon to post up a copy of your workbook. Make sure the workbook has the UDF I gave installed and the Conditional Formatting formulas I explained entered as well. It's your work I'd like to test.

    Also, I'm changing your USERNAME to remove the @yahoo.com, so you will need to login with just hrs4545 from now on.

  8. #8
    Registered User
    Join Date
    02-22-2013
    Location
    Rajahmundry
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Searching for a value in multiple sheets

    Respected Sir

    I am herewith attached two files; one is excel sheet which consists of multiple worksheets (including macro) and other one is snapshot of requirement in jpg format. If we type the compound name like "Methyl Tetradecanoate" ( as shown in snapshot), it has to search in column 'K' of all worksheets, if a match is found, those rows will be copied into a new worksheet. Then I will give next compound name and repeat this for one by one. PLS DO THE HELP.
    Attached Images Attached Images
    Attached Files Attached Files

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

    Re: Searching for a value in multiple sheets

    You installed the new function into a module. Good job.

    Then you did nothing with it. Follow these SECOND set of instructions taken from post #2. This applies conditional formatting to column K of all your sheets to accomplish your desired results.

    Quote Originally Posted by JBeaucaire
    Now, since you want the duplicated cells to be "highlighted", I would use this new function as a Conditional Formatting formula.

    1) Highlight all the sheets.
    2) Highlight column K
    3) Create a conditional formatting rule in that column with the color of your choosing and the formula:
    =CountInSheets(K1, 11)>1

    Now, all the items that appear in more than one place will highlight the color you selected. Here's your workbook back with that installed and working.
    You might have to do these steps on one sheet at a time.
    Last edited by JBeaucaire; 02-25-2013 at 11:47 AM.

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

    Re: Searching for a value in multiple sheets

    Here's a macro that will add the conditional formatting for you:

    Please Login or Register  to view this content.
    It does require the original function given, too, so both will need to be in the workbook.

  11. #11
    Registered User
    Join Date
    02-22-2013
    Location
    Rajahmundry
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Searching for a value in multiple sheets

    Thanks for your reply sir. In that file, all duplicate values are highlighted in multiple work sheets and the count also displayed sir. Actually, I need the result as "those duplicate rows (based on value of K) from all sheets has to be copied into another sheet (in order) sir. For example "Propanoicacid, decyl ester" showed the count as '3' times. These three rows from multiple sheets will be copied into another work sheet (Say 'result.xls'). Similarly next compound "ISOCHIAPIN B" counted as 8. These eight rows has to be copied / appended after 3 rows of the file result.xls. The last column of each row of 'result.xls' is the name of the excel sheet(s) where these compound name was found. Similarly for all duplicate cells sir. Because I am new to this, PLS KINDLY HELP ME SIR.
    Last edited by hrs4545; 02-26-2013 at 01:39 AM. Reason: modified

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

    Re: Searching for a value in multiple sheets

    It's crazy. Just copy all the data from all sheets into a single worksheet. Then sort the list by column K to get all like rows together. Then flag every row that has no duplicates in column K and delete them.

    Run this macro with your data workbook onscreen. Be sure to edit the PATH where you want the new file saved:
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    02-22-2013
    Location
    Rajahmundry
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Searching for a value in multiple sheets

    I attached four excel sheets. In the first workbook 'FAME.xls' contains 3 worksheets names 1,2,3 and a macro to combine them into a new worksheet named 'conslidated'. I copied that worksheet into a new file and named it as 'Book2'(that contains a single file contains all records of worksheet 1,2,3). I executed the macro 'duplicates'(given by you) and the result file is 'result.xls'. In that file, I am not getting the source address of each row i.e., where it is originally placed. The actual output required is shown in 'result-required.xls'. The last column 'L' indicates the file name followed by row position. 2-2 means file name 2, row is 2. Similarly all four row positions are displayed. I tried a lot but failed to get it. Pls help me sir
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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