I'm new to the website, so I apologize if it sounds like I'm posting a question that's already been answered. I´ve been looking for a macro that creates unique combinations for a given list. For example.
Column A Column B Column C Column D
A 1 black Old
2 white new
I got this macro from the web but i would like to modify the Debug.Print to output to a worksheet so the result appear in the next column. Also what should i need to modify to running the code at row 2.
This is the code i found
Option Explicit
Sub Combinations()
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
Dim a As Range, b As Range, c As Range, d As Range
Dim x&, y&, z&, w&
For x = 1 To ws.Range("A" & Rows.Count).End(xlUp).Row
Set a = ws.Range("A" & x)
For y = 1 To ws.Range("B" & Rows.Count).End(xlUp).Row
Set b = ws.Range("B" & y)
For z = 1 To ws.Range("C" & Rows.Count).End(xlUp).Row
Set c = Range("C" & z)
For w = 1 To ws.Range("D" & Rows.Count).End(xlUp).Row
Set d = ws.Range("D" & w)
Debug.Print a & vbTab & b & vbTab & c & vbTab & d
Set d = Nothing
Next
Set c = Nothing
Next
Set b = Nothing
Next y
Set a = Nothing
Next x
End Sub
Thanks in advance
Bookmarks