+ Reply to Thread
Results 1 to 7 of 7

search a range of cells for text and return that text

  1. #1
    Registered User
    Join Date
    05-31-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2000
    Posts
    18

    search a range of cells for text and return that text

    Hi everyone

    I need to use a function or a macro that will search a range of cells, one only of which will contain a number, and when if finds it, it copies that number to a certain cell. The problem is the number could be anything so I need it to search for any cell that has a value really and return that value. I hope the example below helps.PS there will always be a number in some of the cells in the range and there will only ever be one number.


    A B C
    1 29 300
    2 15 35
    3 11 14 2
    4 18 200
    5 125 420

    In the above example I want excel to search in range C1-C5 and if it finds a value ( in this case 2 ) then return the value in say cell D3. I cant tell it to look for 2 in the range as the next time the number could be anything, all that remain constant is that it will be a single value in an otherwise blank range

    Thanks for the help

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: search a range of cells for text and return that text

    Not sure I understand, but does this help??

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-31-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2000
    Posts
    18

    Re: search a range of cells for text and return that text

    Thanks john, I see my example didn't really show up well. See if this example makes sense.

    Column A
    blank cell
    blank cell
    blank cell
    4
    blank cell
    blank cell

    I have written blank cell here so it shows up but in the spreadsheet it would just be a blank cell. Now I need the macro or formula to look down the range from A1:A6 and see which one has a number in it, and return that value (in this case 4) in another cell say D3. Does this make sense?

    Your macro dosen't work as I dont know what the number is going to be, all I need it to do is to copy the number from one cell to another but I need it to look through the range of cells to see where the number is as it could be anywhere in the range and could be any number.
    In plain speak I want it to look through a list of cells and whichever cell has a value in it then show that value on another place on the spreadsheet

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: search a range of cells for text and return that text

    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-31-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2000
    Posts
    18

    Re: search a range of cells for text and return that text

    Thanks John for all your help

    I got it sorted in the meantime with a google search and came up with this =LOOKUP(REPT("z",255),A1:A9)

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: search a range of cells for text and return that text

    You're welcome. Glad you got a solution.

  7. #7
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: search a range of cells for text and return that text

    Hello strucad,

    JOHN H.DAVIS came very close to the ideal VBA solution. However, you could also do it with a simple formula.

    In the attached Workbook, I illustrate a couple of options. Play around with it, and feel free to use it as you like.i.e. VBA or a Formula.
    Attached Files Attached Files
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  8. #8
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: search a range of cells for text and return that text

    Post duplicated.:( Please delete this one.
    Attached Files Attached Files
    Last edited by Winon; 09-05-2013 at 03:58 AM. Reason: Workbook did not upload

+ 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. How to search for a value within a range and return a corresponding text identifier
    By CA_needing_help in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-20-2013, 10:16 PM
  2. [SOLVED] Return specific text if a different text is contained anywhere in a range of cells
    By ciayers in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-06-2013, 05:54 PM
  3. Replies: 5
    Last Post: 03-08-2012, 01:50 AM
  4. Search Text of Cell in a range and return the contents
    By shanipk82 in forum Excel General
    Replies: 3
    Last Post: 11-26-2010, 01:34 PM
  5. Search text string for range of text values - return match
    By crugg in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-03-2010, 09:55 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