I was looking through the archives today and saw a request for a formula or Macro to calculate the

**Combination**from a

**Lex**number.

Unfortunately I couldn't find it again to paste the link.

Anyway, here is a Macro that will calculate this.

Change the

**nMaxF**value as needed.

Put the

**Lex**number in cell

**A1**and run the Macro below.

Option Explicit

Option Base 1

Const nMinA As Integer = 1

Const nMaxF As Integer = 49

Sub Lex2Combination()

Dim A As Integer, B As Integer, C As Integer, D As Integer, E As Integer, F As Integer

Dim nVal As Double, nLex As Double

With Application

.ScreenUpdating = False: .Calculation = xlCalculationManual: .DisplayAlerts = False

End With

Range("A1").Select

nVal = Range("A1").Value

nLex = 0

For A = nMinA To nMaxF - 5

For B = A + 1 To nMaxF - 4

For C = B + 1 To nMaxF - 3

For D = C + 1 To nMaxF - 2

For E = D + 1 To nMaxF - 1

For F = E + 1 To nMaxF

nLex = nLex + 1

If nLex = nVal Then

Range("B1").Value = A: Range("C1").Value = B

Range("D1").Value = C: Range("E1").Value = D

Range("F1").Value = E: Range("G1").Value = F

Exit Sub

End If

Next F: Next E: Next D: Next C: Next B: Next A

With Application

.DisplayAlerts = True: .Calculation = xlCalculationAutomatic: .ScreenUpdating = True

End With

End Sub

Have FUN!

I do

**HATE**the fact that we can't post using the

**Code**tags which would correctly indent the code.

Regards,

PAB

-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-

12:45, restate my assumptions.

Mathematics is the language of nature.

Everything around us can be represented and understood through numbers.

If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.