Hi Jack. See how you get on with the code below, which can be pasted into the code section of Excel to run as a macro. Hit [ALT]+[F11], then on the left hand side under 'Project - VBAProject', double-click on 'This Workbook'. You can then paste all of the code below, and can be run from the spreadsheet by pressing [ALT]+[F8] to bring up the macros combo box.
I've limited the digits in the draw to only occur only once, whereas other digits can occur twice.
Any comments/feedback welcome.
-----------
'
' Macro assumes three different digits
' Cells A1, B1 and C1 must contain the three digits from the draw
' The arrangements are output in columns A, B, C, starting from the second row
' - The first digit is shown in column B, then column C
' - The second digit is shown in column A, then column C
' - The third digit is shown in column A, then column B
'
Sub Pick3Perm()
Const CODED_PERMS = "121313122123231231233213"
Const RNG_DRAW_CELL = "A1"
Const RNG_OUTPUT_CELL = "A2"
'
Dim b As Byte
Dim b1 As Byte
Dim b2 As Byte
Dim blnOutput As Boolean
Dim bytOtherDigitPos1 As Byte
Dim bytOtherDigitPos2 As Byte
Dim bytRptDigitIPPos As Byte
Dim bytRptDigitOPPos As Byte
Dim i As Integer
Dim rngDraw As Range
Dim rngOutput As Range
'
' Setup
Set rngDraw = Range(RNG_DRAW_CELL)
Set rngOutput = Range(RNG_OUTPUT_CELL)
'
' Cycle through the different options
i = 0
For b = 0 To 5
bytRptDigitIPPos = Val(Mid$(CODED_PERMS, 4 * b + 1, 1)) - 1
bytRptDigitOPPos = Val(Mid$(CODED_PERMS, 4 * b + 2, 1)) - 1
bytOtherDigitPos1 = Val(Mid$(CODED_PERMS, 4 * b + 3, 1)) - 1
bytOtherDigitPos2 = Val(Mid$(CODED_PERMS, 4 * b + 4, 1)) - 1
'
' Output the arrangements
For b1 = 0 To 9
For b2 = 0 To 9
blnOutput = True
If b1 = rngDraw.Offset(0, 0).Value Then
blnOutput = False
ElseIf b1 = rngDraw.Offset(0, 1).Value Then
blnOutput = False
ElseIf b1 = rngDraw.Offset(0, 2).Value Then
blnOutput = False
ElseIf b2 = rngDraw.Offset(0, 0).Value Then
blnOutput = False
ElseIf b2 = rngDraw.Offset(0, 1).Value Then
blnOutput = False
ElseIf b2 = rngDraw.Offset(0, 2).Value Then
blnOutput = False
End If
'
If blnOutput Then
rngOutput.Offset(i, bytOtherDigitPos1).Value = b1
rngOutput.Offset(i, bytOtherDigitPos2).Value = b2
rngOutput.Offset(i, bytRptDigitOPPos).Value = rngDraw.Offset(0, bytRptDigitIPPos).Value
i = i + 1
End If
Next b2
Next b1
Next b
'
' Tidy up
Set rngDraw = Nothing
Set rngOutput = Nothing
End Sub