Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 2 sheets in excel, each with 10 rows. Is there some sort of "cross-join" formula/macro in Excel that allows me to create a 3rd sheet with all rows cross-joined (100 rows in total).

share|improve this question
up vote 5 down vote accepted

This article contains a script that might help :

Need a cross join of the rows from two excel sheets

share|improve this answer

If using OLEDB is not an options below function can be used to generate cross product

Option Base 1

Function Cross_Product_range(r1 As Range, r2 As Range) As Variant
    Cross_Product_range = Cross_Product_array(r1.Value, r2.Value)
End Function

Function Cross_Product_array(a1 As Variant, a2 As Variant) As Variant
    On Error GoTo ErrorHandler
    Dim TempArray(), k, m
    ReDim TempArray(UBound(a1) * UBound(a2), UBound(a1, 2) + UBound(a2, 2))
    k = 1
    For i = 1 To UBound(a1)
        For j = 1 To UBound(a2)
            m = 1
            For u = 1 To UBound(a1, 2)
                TempArray(k, m) = a1(i, u)
                m = m + 1
            For u = 1 To UBound(a2, 2)
                TempArray(k, m) = a2(j, u)
                m = m + 1
            k = k + 1
    Cross_Product_array = TempArray
    Exit Function
    Debug.Print Err
End Function

Once above function is added to vba module, To produce cross product of A1:B5 and C1:D5 select target cells (say E1:H25) and enter formula and use ctrl + shift + enter

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.