3 variables composed in all different ways

LarsSJensen

New Member
Joined
Feb 16, 2018
Messages
10
Hi

I need to create a column with groups

so the first variable is from 0 to 14
the next is from 0 to 14
and the last is 0 to 21

i need an easy way for excel to write all the different combinations down

e.g

0-0-0
1-0-0
2-0-0

and so on

or else i need to write them all down

please help
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Try:-
Results in Column "A"
Code:
[COLOR="Navy"]Sub[/COLOR] MG06Jun00
[COLOR="Navy"]Dim[/COLOR] A, B, C, d
[COLOR="Navy"]For[/COLOR] A = 0 To 14
    [COLOR="Navy"]For[/COLOR] B = 0 To 14
        [COLOR="Navy"]For[/COLOR] C = 0 To 21
        d = d + 1
        [COLOR="Navy"]With[/COLOR] Cells(d, 1)
            .NumberFormat = "@"
            .Value = C & "-" & B & "-" & A
        [COLOR="Navy"]End[/COLOR] With
        [COLOR="Navy"]Next[/COLOR] C
    [COLOR="Navy"]Next[/COLOR] B
[COLOR="Navy"]Next[/COLOR] A
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
A slight modification to Mick's code.

It does what it is supposed to, but takes about 30 seconds to run (at least on my computer), and locks things up while it is running.
You can add a few lines to make it only take 2-3 seconds to run, like this:
Code:
Sub MG06Jun00()
Dim A, B, C, d
[COLOR=#ff0000]Application.ScreenUpdating = False[/COLOR]
For A = 0 To 14
    For B = 0 To 14
        For C = 0 To 21
        d = d + 1
        With Cells(d, 1)
            .NumberFormat = "@"
            .Value = C & "-" & B & "-" & A
        End With
        Next C
    Next B
Next A
[COLOR=#ff0000]Application.ScreenUpdating = True[/COLOR]
End Sub
 
Last edited:
Upvote 0
tbh i dont know how to work with code like that in excel, so i used 4 formulas

=IF(ROW()-ROW($F$1)+1<=COUNTA(A:A)*COUNTA(B:B)*COUNTA(C:C);INDEX(A:A;INT((ROW()-ROW($F$1))/(COUNTA(B:B)*COUNTA(C:C))+1));"")

and

=IF(ROW()-ROW($F$1)+1<=COUNTA(A:A)*COUNTA(B:B)*COUNTA(C:C);INDEX(B:B;MOD(ROW()-ROW($F$1);COUNTA(B:B))+1);"")

and

=IF(ROW()-ROW($F$1)+1<=COUNTA(A:A)*COUNTA(B:B)*COUNTA(C:C);INDEX(C:C;MOD(ROW()-ROW($F$1);COUNTA(C:C))+1);"")

and then

=IF(F1<>" ";F1&G1&H1;"""")


but if someone would like to explain to me how to use the code, that would be nice.



my data is like this.

A B C
[TABLE="width: 198"]
<colgroup><col span="2"><col></colgroup><tbody>[TR]
[TD]0-[/TD]
[TD]0[/TD]
[TD]CASH[/TD]
[/TR]
[TR]
[TD]1-[/TD]
[TD]1[/TD]
[TD]EK[/TD]
[/TR]
[TR]
[TD]2-[/TD]
[TD]2[/TD]
[TD]FORUD[/TD]
[/TR]
[TR]
[TD]3-[/TD]
[TD]3[/TD]
[TD]LM[/TD]
[/TR]
[TR]
[TD]4-[/TD]
[TD]4[/TD]
[TD]LM08[/TD]
[/TR]
[TR]
[TD]5-[/TD]
[TD]5[/TD]
[TD]LM10[/TD]
[/TR]
[TR]
[TD]6-[/TD]
[TD]6[/TD]
[TD]LM14[/TD]
[/TR]
[TR]
[TD]7-[/TD]
[TD]7[/TD]
[TD]LM15[/TD]
[/TR]
[TR]
[TD]8-[/TD]
[TD]8[/TD]
[TD]LM20[/TD]
[/TR]
[TR]
[TD]9-[/TD]
[TD]9[/TD]
[TD]LM25[/TD]
[/TR]
[TR]
[TD]10-[/TD]
[TD]10[/TD]
[TD]LM30[/TD]
[/TR]
[TR]
[TD]11-[/TD]
[TD]11[/TD]
[TD]LM30-LØN[/TD]
[/TR]
[TR]
[TD]12-[/TD]
[TD]12[/TD]
[TD]LM40[/TD]
[/TR]
[TR]
[TD]13-[/TD]
[TD]13[/TD]
[TD]LM45[/TD]
[/TR]
[TR]
[TD]14-[/TD]
[TD]14[/TD]
[TD]LM55[/TD]
[/TR]
[TR]
[TD]0r-[/TD]
[TD][/TD]
[TD]LM60[/TD]
[/TR]
[TR]
[TD]1r-[/TD]
[TD][/TD]
[TD]LM90[/TD]
[/TR]
[TR]
[TD]2r-[/TD]
[TD][/TD]
[TD]NET08[/TD]
[/TR]
[TR]
[TD]3r-[/TD]
[TD][/TD]
[TD]NET14[/TD]
[/TR]
[TR]
[TD]4r-[/TD]
[TD][/TD]
[TD]NET20[/TD]
[/TR]
[TR]
[TD]5r-[/TD]
[TD][/TD]
[TD]NET25[/TD]
[/TR]
[TR]
[TD]6r-[/TD]
[TD][/TD]
[TD]NET30[/TD]
[/TR]
[TR]
[TD]7r-[/TD]
[TD][/TD]
[TD]NET45[/TD]
[/TR]
[TR]
[TD]8r-[/TD]
[TD][/TD]
[TD]NET60[/TD]
[/TR]
[TR]
[TD]9r-[/TD]
[TD][/TD]
[TD]NET90[/TD]
[/TR]
[TR]
[TD]10r-[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]11r-[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]12r-[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]13r-[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]14r-[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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