+ Reply to Thread
Results 1 to 5 of 5

VLOOKUP with merged cell

  1. #1
    Registered User
    Join Date
    11-27-2018
    Location
    USA
    MS-Off Ver
    2010
    Posts
    1

    VLOOKUP with merged cell

    I am attaching the file with my problem and the output I need...
    Attached Files Attached Files

  2. #2
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 365
    Posts
    2,406

    Re: VLOOKUP with merged cell

    For Seller, put this on D3 and ENTERED as ARRAY FORMULAS:
    =IFERROR(INDEX(LOOKUP(ROW($A$3:$A$13),ROW($A$3:$A$13)/($A$3:$A$13<>""),$A$3:$A$13),MATCH(0,INDEX(COUNTIF($D$2:D2,LOOKUP(ROW($A$3:$A$13),ROW($A$3:$A$13)/($A$3:$A$13<>""),$A$3:$A$13)&""),0,0),0)),"")

    For Products, put this on E3 and just ENTERED as REGULAR FORMULAS:
    =IF(IFERROR(INDEX($B$2:$B$13,AGGREGATE(15,6,(ROW($B$2:$B$13)-MIN(ROW($B$2:$B$13))+1)/(LOOKUP(ROW($A$2:$A$13),ROW($A$2:$A$13)/($A$2:$A$13<>""),$A$2:$A$13)=$D3),1)),"")="","",IFERROR(INDEX($B$2:$B$13,AGGREGATE(15,6,(ROW($B$2:$B$13)-MIN(ROW($B$2:$B$13))+1)/(LOOKUP(ROW($A$2:$A$13),ROW($A$2:$A$13)/($A$2:$A$13<>""),$A$2:$A$13)=$D3),1)),""))&IF(IFERROR(INDEX($B$2:$B$13,AGGREGATE(15,6,(ROW($B$2:$B$13)-MIN(ROW($B$2:$B$13))+1)/(LOOKUP(ROW($A$2:$A$13),ROW($A$2:$A$13)/($A$2:$A$13<>""),$A$2:$A$13)=$D3),2)),"")="","",", "&IFERROR(INDEX($B$2:$B$13,AGGREGATE(15,6,(ROW($B$2:$B$13)-MIN(ROW($B$2:$B$13))+1)/(LOOKUP(ROW($A$2:$A$13),ROW($A$2:$A$13)/($A$2:$A$13<>""),$A$2:$A$13)=$D3),2)),""))&IF(IFERROR(INDEX($B$2:$B$13,AGGREGATE(15,6,(ROW($B$2:$B$13)-MIN(ROW($B$2:$B$13))+1)/(LOOKUP(ROW($A$2:$A$13),ROW($A$2:$A$13)/($A$2:$A$13<>""),$A$2:$A$13)=$D3),3)),"")="","",", "&IFERROR(INDEX($B$2:$B$13,AGGREGATE(15,6,(ROW($B$2:$B$13)-MIN(ROW($B$2:$B$13))+1)/(LOOKUP(ROW($A$2:$A$13),ROW($A$2:$A$13)/($A$2:$A$13<>""),$A$2:$A$13)=$D3),3)),""))&IF(IFERROR(INDEX($B$2:$B$13,AGGREGATE(15,6,(ROW($B$2:$B$13)-MIN(ROW($B$2:$B$13))+1)/(LOOKUP(ROW($A$2:$A$13),ROW($A$2:$A$13)/($A$2:$A$13<>""),$A$2:$A$13)=$D3),4)),"")="","",", "&IFERROR(INDEX($B$2:$B$13,AGGREGATE(15,6,(ROW($B$2:$B$13)-MIN(ROW($B$2:$B$13))+1)/(LOOKUP(ROW($A$2:$A$13),ROW($A$2:$A$13)/($A$2:$A$13<>""),$A$2:$A$13)=$D3),4)),""))&IF(IFERROR(INDEX($B$2:$B$13,AGGREGATE(15,6,(ROW($B$2:$B$13)-MIN(ROW($B$2:$B$13))+1)/(LOOKUP(ROW($A$2:$A$13),ROW($A$2:$A$13)/($A$2:$A$13<>""),$A$2:$A$13)=$D3),5)),"")="","",", "&IFERROR(INDEX($B$2:$B$13,AGGREGATE(15,6,(ROW($B$2:$B$13)-MIN(ROW($B$2:$B$13))+1)/(LOOKUP(ROW($A$2:$A$13),ROW($A$2:$A$13)/($A$2:$A$13<>""),$A$2:$A$13)=$D3),5)),""))
    Attached Files Attached Files

  3. #3
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2503
    Posts
    13,702

    Re: VLOOKUP with merged cell

    Hi Ran78. Welcome to the forum.

    Another way. For Seller in D3 and filled down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    For the Products the attached uses a helper column. The offset row headers in column A cause difficulties similar to merged cells the helper column is one remedy. In C3 and filled down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Then to group the Products this borrowed user defined function by tigeravatar wrapped around the formula at the bottom of this post. It is called Concatall.

    PHP Code: 
    'tigeravatar ExcelForum
    Public Function ConcatAll(ByVal varData As Variant, Optional ByVal sDelimiter As String = vbNullString, Optional ByVal bUnique As Boolean = False) As String
    '
    Created by TigerAvatar at www.excelforum.comSeptember 2012
    'Purpose is to concatenate many strings into a single string
    '
    Can be used with arraysrange objects, and collections
        
        Dim DataIndex 
    As Variant    'Used to loop through arrays, range objects, and collections
        Dim strResult As String     '
    Used to build the result string
        
        
    'Test if varData is an Array, Range, or Collection
        If IsArray(varData) _
        Or TypeOf varData Is Range _
        Or TypeOf varData Is Collection Then
            
            '
    Found to be an, array, range object, or collection
            
    'Loop through each item in varData
            For Each DataIndex In varData
                '
    Check if the item isn't empty
                If Len(DataIndex) > 0 Then
                    '
    Found the item isn't empty, check if user specified bUnique as True
                    If bUnique = True Then
                        '
    bUnique is truecheck if the item has been included in the result yet
                        
    If InStr(1"||" strResult "||""||" DataIndex "||"vbTextCompare) = 0 Then
                            
    'Item has not been included in the result, add item to the result
                            strResult = strResult & "||" & DataIndex
                        End If
                    Else
                        '
    bUnique is not trueadd item to the result
                        strResult 
    strResult "||" DataIndex
                    End 
    If
                
    End If
            
    Next DataIndex
            
            
    'Correct strResult to remove beginning delimiter and convert "||" to the specified sDelimiter
            strResult = Replace(Mid(strResult, 3), "||", sDelimiter)
            
        Else
            '
    Found not to be an array, range object, or collection
            
    'Simply set the result = varData
            strResult = varData
        End If
        
        '
    Output result
        ConcatAll 
    strResult
        
    End 
    Function 
    Although it is already installed in the attached for future reference here is how to install VBA code.

    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the code into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm) or *.xlsb


    Note this must be array entered. If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Dave

  4. #4
    Forum Contributor
    Join Date
    10-30-2003
    Location
    Singapore
    MS-Off Ver
    Excel 2019
    Posts
    197

    Re: VLOOKUP with merged cell

    Another formula option with helper column

    1] In "helper" C3, copied down :

    =IF(LOOKUP("zz",A$2:A4)=LOOKUP("zz",A$1:A3),B3&" "&C4,B3)

    p.s. if you wanted to hide the helper column, C3 >> Custom Cell format, enter ;;; >> copied down

    2] In "output" D3, copied down :

    =IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW(A$3:A$50)/(A$3:A$50<>""),ROWS($1:1))),"")

    3] In "output" E3, copied down :

    =IF(D3="","",VLOOKUP(D3,A$3:C$13,3,0))

    Regards
    Bosco
    Attached Files Attached Files

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2503
    Posts
    13,702

    Re: VLOOKUP with merged cell

    @ Bosco

    I really like your helper column approach. Very cool!

+ 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. Replies: 1
    Last Post: 09-27-2018, 11:22 AM
  2. Limit merged cell data; Place excess into next merged cell down
    By coreytroy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-06-2013, 10:35 PM
  3. [SOLVED] VB:ClearContents Error on Merged Cell - But I dont have Any Merged Cell
    By cychua in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 01-24-2013, 06:33 AM
  4. Replies: 2
    Last Post: 11-02-2011, 10:06 AM
  5. Excel 2007 : Vlookup help with merged cell data.
    By here.to.code in forum Excel General
    Replies: 3
    Last Post: 02-17-2011, 10:25 PM
  6. [SOLVED] Copy merged cell, paste as merged cell
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-18-2009, 02:35 PM
  7. [SOLVED] how do i link merged cells to a merged cell in another worksheet.
    By ibbm in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-27-2006, 06:45 PM

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