+ Reply to Thread
Results 1 to 3 of 3

Multiple VLookUp w. numbered sequencing and line break

  1. #1
    Registered User
    Join Date
    06-07-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    7

    Multiple VLookUp w. numbered sequencing and line break

    Hi Everyone!


    I'm having some trouble finishing up a code which aims to search a defined range using vlookup, then returning the results into a single cell, with numbering and line breaks. For example if three rows of data contain the results: pencil, pen, paper, I want the formula to return the results as:

    1) Pencil
    2) Pen
    3) Paper


    Currently the code I have returns it as

    Pencil
    Pen
    Paper

    without the numbering. If anyone knows how to do this, please help!! Thank you!

    Public Function FindSeries(TRange As Range, MatchWith As String)

    For Each cell In TRange
    If cell.Value = MatchWith Then
    x = x & cell.Offset(0, 1).Value & vbNewLine
    End If
    Next cell

    FindSeries = Left(x, (Len(x) - 2))

    End Function





    SOLUTION BY Roger Govier

    Public Function FindSeries(TRange As Range, MatchWith As String)
    dim i as long
    i= 1
    For Each cell In TRange
    If cell.Value = MatchWith Then
    x = x & i & ") " & cell.Offset(0, 1).Value & vbNewLine
    i=i+1
    End If
    Next cell

    FindSeries = Left(x, (Len(x) - 2))

    End Function
    Last edited by the.white.hole; 06-08-2011 at 06:35 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    07-17-2005
    Location
    Abergavenny, Wales, UK
    MS-Off Ver
    XL2003, XL2007, XL2010, XL2013, XL2016
    Posts
    608

    Re: Multiple VLookUp w. numbered sequencing and line break

    Hi

    Try
    Please Login or Register  to view this content.
    --
    Regards
    Roger Govier
    Microsoft Excel MVP

  3. #3
    Registered User
    Join Date
    06-07-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Multiple VLookUp w. numbered sequencing and line break

    NICE! It worked!!


    Thanks!!

+ 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