+ Reply to Thread
Results 1 to 3 of 3

Thread: UDF to Display Results Vertically Instead of One Cell Horizontally

  1. #1
    Registered User
    Join Date
    02-14-2008
    Posts
    29

    UDF to Display Results Vertically Instead of One Cell Horizontally

    Hello,

    I have the following UDF that pulls all values for a matching criteria.
    Currently, the list is displayed horizontally in one cell. How can I achieve displaying the results vertically with each result occupying one cell?


    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 & ", " 
            End If 
        Next cell 
         
        FindSeries = Left(x, (Len(x) - 2)) 
         
    End Function
    Can that be done through this or do I need another piece of code?

    Thanks for any help.

  2. #2
    Valued Forum Contributor MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    888
    Hi, You could Modify you function,or insert as new function.
    If you insert this function in a column level with your range and Drag it down to the bottom, you will get you results, or did you want only the positive answers in a list ???
    Public Function FindSeries(TRange As Range, MatchWith As String)
         Dim Mch
        If TRange.Value = MatchWith Then
               Mch = TRange.Offset(0, 1).Value
              End If
        
           FindSeries = Mch
         
    End Function
    Regards Mick

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979
    Hello Snake10,

    I've added the code to place the text vertical in the cell with the first letter at the bottom. You can change the text orientation by degree. The range is from -90 to 90.
    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 & ", " 
            End If 
        Next cell 
         
        ActiveCell.Orientation = 90
        FindSeries = Left(x, (Len(x) - 2)) 
         
    End Function
    Sincerely,
    Leith Ross

+ 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.2.0