+ Reply to Thread
Results 1 to 4 of 4

Comparing Cell to Range, is it possible to display all matches found in a single cell?

Hybrid View

WSICKLES44444 Comparing Cell to Range, is... 10-04-2013, 10:14 AM
tony h Re: Comparing Cell to Range,... 10-04-2013, 02:59 PM
WSICKLES44444 Re: Comparing Cell to Range,... 10-04-2013, 03:04 PM
tony h Re: Comparing Cell to Range,... 10-04-2013, 05:20 PM
  1. #1
    Registered User
    Join Date
    09-13-2013
    Location
    Boston, MA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Comparing Cell to Range, is it possible to display all matches found in a single cell?

    For example, if I had:
    Pen $1.00
    Book $8.00
    Tape $2.00
    Pen $1.20

    And I am looking for all matches of Pen, have the cell display:

    $1.00, $1.20

    Let me know if you need any more info, thanks!

  2. #2
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: Comparing Cell to Range, is it possible to display all matches found in a single cell?

    you can do it in VBA but I don't know how to do it with formulae unless the number of lines of data and types of data are quite limited.


    click on the * Add Reputation if this was useful or entertaining.

  3. #3
    Registered User
    Join Date
    09-13-2013
    Location
    Boston, MA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Comparing Cell to Range, is it possible to display all matches found in a single cell?

    Thanks Tony, I was hoping to avoid VBA

  4. #4
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: Comparing Cell to Range, is it possible to display all matches found in a single cell?

    Try this.

    paste the code below into a VBA module. And then use this formula =myFunction( "pen" , H5:I8 ) The H5:I8 will need to be changed to the two column range you have your data in.
    Function myFunction(ByVal KeyValue As String, ByRef Data2Columns As Range) As String
        
        Dim str As String
        Dim r As Range
        Dim rng As Range
        
        Set r = Data2Columns.Resize(, 1)
        For Each rng In r
            If rng.Value = KeyValue Then
                str = str & ", " & rng.Offset(, 1).Value
            End If
        Next
        If str = "" Then
            myFunction = ""
        Else
            myFunction = Mid(str, 3, 1000)
        End If
    End Function

+ 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. Display Cell within VLookup range that excel thinks matches the VLookup Value
    By headachexcelperson in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-04-2013, 04:56 PM
  2. If one cell matches another display a value in adjacent cell
    By Garfield779 in forum Excel General
    Replies: 1
    Last Post: 07-07-2011, 11:49 AM
  3. display a single cell text from a range
    By royal blue in forum Excel - New Users/Basics
    Replies: 15
    Last Post: 04-06-2009, 02:26 AM
  4. Replies: 2
    Last Post: 07-14-2008, 03:24 PM
  5. [SOLVED] Horizontal arrow on cell edge and double-click, no matches found.
    By Vic Tarrazi in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-12-2006, 12:20 PM

Tags for this Thread

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