Trying to execute this code

spedomes

Board Regular
Joined
Dec 13, 2008
Messages
61
Hi, Kaps kindly gave me this code to work out all the possible 1st,2nd,3rd combinations of a 6 dog race. I am trying to execute it. I have entered it into a module but cannot see it in the Macros. I realise it's something basic but can someone point me in the right direction
Many thanks
Mike

Public Sub List_All_Combinations(No_Of_Dogs As Long)
Dim Top_Cell As Range
Dim i As Long
Dim j As Long
Dim k As Long
Dim r As Long
r = 1
Set Top_Cell = Sheets("Sheet1").Range("A1")

For i = 1 To No_Of_Dogs
For j = 1 To No_Of_Dogs
For k = 1 To No_Of_Dogs
If ((i <> j) And (i <> k) And (j <> k)) Then

With Top_Cell.Offset(r, 0)
.Value = i & j & k
End With

With Top_Cell.Offset(r, 1)
.Value = r
End With

r = r + 1

End If

Next k

Next j
Next i

End Sub
 

Some videos you may like

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
L

Legacy 68668

Guest
You need to pass the argument from another sub
try
Rich (BB code):
Sub test()
    List_All_Combinations 6
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,123,402
Messages
5,601,475
Members
414,452
Latest member
Dannysamworth

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
Top