Insert Copied Repeated rows under each Row - can it be done using a tool or vba?

firassali

New Member
Joined
Feb 16, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello,

i have a column as seen below
1676553944696.png


and another Column as seen below
1676553964331.png


I need each row from Column A to have all possible values from criteria 2 to show as follows:
1676554020122.png


Can we do it using an excel tool or VBA? since i will need to do this for 300 criteria 1 and 300 criteria 2

Thank you in advance all,
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi and welcome to MrExcel.

Your data in columns A and B, the results in columns D and E, as shown in the following minisheet:
Dante Amor
ABCDE
1Criteria 1Cirteria 2Criteria 1Cirteria 2
2A1A1
3B2A2
4C3A3
54A4
6B1
7B2
8B3
9B4
10C1
11C2
12C3
13C4
Hoja2


Try this macro:
VBA Code:
Sub CombineCriterias()
  Dim a As Variant, b As Variant
  Dim i As Long, j As Long, k As Long
 
  a = Range("A2", Range("A" & Rows.Count).End(3)).Value
  b = Range("B2", Range("B" & Rows.Count).End(3)).Value
  ReDim c(1 To UBound(a, 1) * UBound(b, 1), 1 To 2)
 
  For i = 1 To UBound(a, 1)
    For j = 1 To UBound(b, 1)
      k = k + 1
      c(k, 1) = a(i, 1)
      c(k, 2) = b(j, 1)
    Next
  Next
 
  Range("D2").Resize(k, 2).Value = c
End Sub

With excel 365 it is possible with functions, in a moment you will have help to achieve it.
 
Upvote 0

Forum statistics

Threads
1,223,956
Messages
6,175,609
Members
452,660
Latest member
Zatman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top