+ Reply to Thread
Results 1 to 3 of 3

Macro to create combinations

  1. #1
    Registered User
    Join Date
    09-20-2013
    Location
    Mexico
    MS-Off Ver
    Excel 2013
    Posts
    2

    Macro to create combinations

    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

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Macro to create combinations

    Not sure what you're trying to do, but there's a workbook at https://app.box.com/s/47b28f19d794b25511be that may be what you want.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    09-20-2013
    Location
    Mexico
    MS-Off Ver
    Excel 2013
    Posts
    2

    Re: Macro to create combinations

    Thank man i will try it

+ 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. Create combinations in same row each one
    By pshls in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-21-2013, 08:38 AM
  2. [SOLVED] Create List of Possible Combinations
    By rhudgins in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-18-2010, 12:38 PM
  3. How do I create a macro to return all possible combinations of letters?
    By k8b in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-31-2010, 10:39 AM
  4. [SOLVED] Create possible combinations from three variables
    By JoeD in forum Excel General
    Replies: 3
    Last Post: 04-20-2006, 05:25 PM
  5. [SOLVED] Macro to add numbers to create combinations that equal certain amo
    By Lauren qt314 in forum Excel General
    Replies: 3
    Last Post: 04-21-2005, 01:06 PM

Tags for this Thread

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