Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Index Generator - Help with Permutations

Hello,

I just joined because I need help with an index generator that I am working on.

I have been asked to create an index of all possible combinations of atributes from different sheets. For example, I may have three sheets:

Size Sheet
Small
Medium
Large

Magnitude Sheet
Dark
Dim
Average
Bright

Weight Sheet
Light
Manageable
Heavy

I would need to assign unqiue index numbers to each line item on each sheet (which I have already done), and create a macro which lists every possible combination of the attributes on another sheet (the index). An example index might look like this:

ID Description
01_01_01 Small_Dark_Light
.....
....
03_01_02 Large_Dark_Manageable
.....
.....

and so on, but for ALL possible combinations of the attributes. You should know that I have far more line items than I list in the example here, but the total number of line items should fall below the excel max of 65k.

I would post my current VBA code for his, but I am so sure its completely wrong that I would prefer a fresh start.

Any help that someone could give would be much appreciated.

Regards,

Garrett


Submitted via EggHeadCafe - Software Developer Portal of Choice
How to reference Assemblies in the GAC
http://www.eggheadcafe.com/tutorials...-assembli.aspx
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Index Generator - Help with Permutations

Garrett,

Is it always three sheets?

Let's say that you have your lists in column A of Sheet1, Sheet2, and Sheet3, and those are the only
sheets in your workbook. All else is blank. Run the macro below.

HTH,
Bernie
MS Excel MVP

Sub MakeCombos()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim Sh1 As Worksheet
Dim Sh2 As Worksheet
Dim Sh3 As Worksheet
Dim Sh4 As Worksheet

Set Sh1 = Worksheets(1)
Set Sh2 = Worksheets(2)
Set Sh3 = Worksheets(3)
Set Sh4 = Worksheets.Add(After:=Sheets(3))

For i = 1 To Sh1.Cells(Rows.Count, 1).End(xlUp).Row - 1
Sh1.Cells(i + 1, 2).Value = "'" & Format(i, "00")
Next i
For i = 1 To Sh2.Cells(Rows.Count, 1).End(xlUp).Row - 1
Sh2.Cells(i + 1, 2).Value = "'" & Format(i, "00")
Next i
For i = 1 To Sh3.Cells(Rows.Count, 1).End(xlUp).Row - 1
Sh3.Cells(i + 1, 2).Value = "'" & Format(i, "00")
Next i

myC = 1
For i = 1 To Sh1.Cells(Rows.Count, 1).End(xlUp).Row - 1
For j = 1 To Sh2.Cells(Rows.Count, 1).End(xlUp).Row - 1
For k = 1 To Sh3.Cells(Rows.Count, 1).End(xlUp).Row - 1
myC = myC + 1
Sh4.Cells(myC, 1).Value = "'" & Format(i, "00") & _
"_" & Format(j, "00") & "_" & Format(k, "00")
Sh4.Cells(myC, 2).Value = Sh1.Cells(i + 1, 1).Value & _
"_" & Sh2.Cells(j + 1, 1).Value & "_" & Sh3.Cells(k + 1, 1).Value
Next k
Next j
Next i

End Sub


<Garrett S wrote in message ...
Hello,

I just joined because I need help with an index generator that I am working on.

I have been asked to create an index of all possible combinations of atributes from different
sheets. For example, I may have three sheets:

Size Sheet
Small
Medium
Large

Magnitude Sheet
Dark
Dim
Average
Bright

Weight Sheet
Light
Manageable
Heavy

I would need to assign unqiue index numbers to each line item on each sheet (which I have already
done), and create a macro which lists every possible combination of the attributes on another
sheet (the index). An example index might look like this:

ID Description
01_01_01 Small_Dark_Light
....
...
03_01_02 Large_Dark_Manageable
....
....

and so on, but for ALL possible combinations of the attributes. You should know that I have far
more line items than I list in the example here, but the total number of line items should fall
below the excel max of 65k.

I would post my current VBA code for his, but I am so sure its completely wrong that I would
prefer a fresh start.

Any help that someone could give would be much appreciated.

Regards,

Garrett


Submitted via EggHeadCafe - Software Developer Portal of Choice
How to reference Assemblies in the GAC
http://www.eggheadcafe.com/tutorials...-assembli.aspx



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Combo

Thanks for the quick reply.

There are 5 attribute sheets in total, but I can modify your code, which looks promising!

Appreciate your input, I'll let you know how it works tomorrow.

Regards,

Garrett





Bernie Deitrick wrote:

Garrett,Is it always three sheets?
21-Jan-10

Garrett,

Is it always three sheets?

Let's say that you have your lists in column A of Sheet1, Sheet2, and Sheet3, and those are the only
sheets in your workbook. All else is blank. Run the macro below.

HTH,
Bernie
MS Excel MVP

Sub MakeCombos()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim Sh1 As Worksheet
Dim Sh2 As Worksheet
Dim Sh3 As Worksheet
Dim Sh4 As Worksheet

Set Sh1 = Worksheets(1)
Set Sh2 = Worksheets(2)
Set Sh3 = Worksheets(3)
Set Sh4 = Worksheets.Add(After:=Sheets(3))

For i = 1 To Sh1.Cells(Rows.Count, 1).End(xlUp).Row - 1
Sh1.Cells(i + 1, 2).Value = "'" & Format(i, "00")
Next i
For i = 1 To Sh2.Cells(Rows.Count, 1).End(xlUp).Row - 1
Sh2.Cells(i + 1, 2).Value = "'" & Format(i, "00")
Next i
For i = 1 To Sh3.Cells(Rows.Count, 1).End(xlUp).Row - 1
Sh3.Cells(i + 1, 2).Value = "'" & Format(i, "00")
Next i

myC = 1
For i = 1 To Sh1.Cells(Rows.Count, 1).End(xlUp).Row - 1
For j = 1 To Sh2.Cells(Rows.Count, 1).End(xlUp).Row - 1
For k = 1 To Sh3.Cells(Rows.Count, 1).End(xlUp).Row - 1
myC = myC + 1
Sh4.Cells(myC, 1).Value = "'" & Format(i, "00") & _
"_" & Format(j, "00") & "_" & Format(k, "00")
Sh4.Cells(myC, 2).Value = Sh1.Cells(i + 1, 1).Value & _
"_" & Sh2.Cells(j + 1, 1).Value & "_" & Sh3.Cells(k + 1, 1).Value
Next k
Next j
Next i

End Sub

Previous Posts In This Thread:


Submitted via EggHeadCafe - Software Developer Portal of Choice
Implementing Continuous Scrolling UI Pattern in ASP.NET
http://www.eggheadcafe.com/tutorials...tinuous-s.aspx
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Combo

It should be easy to work out - if you need help modifying the code, post back. And in any event,
let us know if you succeed or not.

HTH,
Bernie
MS Excel MVP


<Garrett S wrote in message ...
Thanks for the quick reply.

There are 5 attribute sheets in total, but I can modify your code, which looks promising!

Appreciate your input, I'll let you know how it works tomorrow.

Regards,

Garrett





Bernie Deitrick wrote:

Garrett,Is it always three sheets?
21-Jan-10

Garrett,

Is it always three sheets?

Let's say that you have your lists in column A of Sheet1, Sheet2, and Sheet3, and those are the
only
sheets in your workbook. All else is blank. Run the macro below.

HTH,
Bernie
MS Excel MVP

Sub MakeCombos()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim Sh1 As Worksheet
Dim Sh2 As Worksheet
Dim Sh3 As Worksheet
Dim Sh4 As Worksheet

Set Sh1 = Worksheets(1)
Set Sh2 = Worksheets(2)
Set Sh3 = Worksheets(3)
Set Sh4 = Worksheets.Add(After:=Sheets(3))

For i = 1 To Sh1.Cells(Rows.Count, 1).End(xlUp).Row - 1
Sh1.Cells(i + 1, 2).Value = "'" & Format(i, "00")
Next i
For i = 1 To Sh2.Cells(Rows.Count, 1).End(xlUp).Row - 1
Sh2.Cells(i + 1, 2).Value = "'" & Format(i, "00")
Next i
For i = 1 To Sh3.Cells(Rows.Count, 1).End(xlUp).Row - 1
Sh3.Cells(i + 1, 2).Value = "'" & Format(i, "00")
Next i

myC = 1
For i = 1 To Sh1.Cells(Rows.Count, 1).End(xlUp).Row - 1
For j = 1 To Sh2.Cells(Rows.Count, 1).End(xlUp).Row - 1
For k = 1 To Sh3.Cells(Rows.Count, 1).End(xlUp).Row - 1
myC = myC + 1
Sh4.Cells(myC, 1).Value = "'" & Format(i, "00") & _
"_" & Format(j, "00") & "_" & Format(k, "00")
Sh4.Cells(myC, 2).Value = Sh1.Cells(i + 1, 1).Value & _
"_" & Sh2.Cells(j + 1, 1).Value & "_" & Sh3.Cells(k + 1, 1).Value
Next k
Next j
Next i

End Sub

Previous Posts In This Thread:


Submitted via EggHeadCafe - Software Developer Portal of Choice
Implementing Continuous Scrolling UI Pattern in ASP.NET
http://www.eggheadcafe.com/tutorials...tinuous-s.aspx



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Permutations John[_33_] Excel Worksheet Functions 2 January 31st 10 09:49 PM
permutations art Excel Worksheet Functions 1 May 8th 09 05:07 PM
Permutations Dave Excel Discussion (Misc queries) 5 July 23rd 07 03:06 PM
Permutations RedChequer Excel Worksheet Functions 9 September 26th 05 03:14 AM
Permutations Henrik Excel Programming 3 December 2nd 04 05:32 AM


All times are GMT +1. The time now is 02:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"