Results 1 to 16 of 16

Vlookup - create new list from existing list based on partial match

Threaded View

  1. #10
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,769

    Re: Vlookup - create new list from existing list based on partial match

    VBA offering:

    Sub Get_List()
    
    Dim loookup() As String
    Dim InArr() As Variant
    Dim OutArr() As Variant
    Dim List() As String
    Dim Destination As Range
    
    lr1 = Cells(Rows.Count, "A").End(xlUp).Row
    InArr = Range("A3:B" & lr1)
    lr2 = Cells(Rows.Count, "E").End(xlUp).Row
    Lookup = Range("E3:E" & lr2)
    ReDim OutArr(1 To 2, 1 To 1)
    
    
    k = 0
    For i = 1 To UBound(InArr, 1)
        For j = 1 To UBound(Lookup, 1)
            If InStr(1, InArr(i, 1), Lookup(j, 1)) Then
               k = k + 1
               ReDim Preserve OutArr(1 To 2, 1 To k)
               OutArr(1, k) = InArr(i, 1)
               OutArr(2, k) = InArr(i, 2)
               Exit For
            End If
        Next j
    Next i
    '
    ' write out results
    '
    
    
    Set Destination = Range("H3")
    Destination.Resize(UBound(OutArr, 2), UBound(OutArr, 1)).Value = Application.Transpose(OutArr)
    
    End Sub
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Press Alt+F11 to open the Visual Basic Editor
    Choose Insert > Module
    Edit > Paste the macro into the module that appeared
    Close the VBEditor
    Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)
    [B][I]
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Compare a list of strings against a list of keywords to return a partial match
    By randomkiwi in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-11-2017, 11:51 PM
  2. [SOLVED] Updating a Master List from a Partial List (VLOOKUP?)
    By jplunkett1 in forum Excel General
    Replies: 7
    Last Post: 07-15-2016, 11:19 AM
  3. [SOLVED] Formula to Create a Partial List from a Complete List
    By slindfors in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-18-2014, 02:44 PM
  4. Copy column based on partial word match in first row and paste into existing workbook
    By David Harris 1987 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-19-2013, 03:52 PM
  5. Copy column based on partial word match in first row and paste into existing workbook
    By David Harris 1987 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-11-2013, 01:02 PM
  6. Copying row based on partial cell match and paste into existing worksheets
    By colinh69 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2011, 02:42 PM
  7. Replies: 1
    Last Post: 06-05-2006, 10:40 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