View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Paul Black Paul Black is offline
external usenet poster
 
Posts: 394
Default Help with a Formula Within a Function Please

Thanks for the Reply Tom,

What I Ideally want is to Include the Function in the Follwing Macro,
so that as it Runs through the Combinations it Checks if the
Lexicographic Number of that Combination is within the Range Set. The
Formula I gave was to Show How it is Calculated in an Excel Formula.
The Macro Below Produces Combinations and then Writes them to a
Worksheet, I Only want Combinations Produced if the Lexicographic
Number is Within the Range Set Please.

Option Explicit
Dim A As Integer, B As Integer, C As Integer, D As Integer, E As
Integer, F As Integer
Dim N As Long
Sub Test()
Range("A1").Select
Application.ScreenUpdating = False
N = 0
For A = 1 To 7
For B = A + 1 To 8
For C = B + 1 To 9
For D = C + 1 To 10
For E = D + 1 To 11
For F = E + 1 To 12
N = N + 1
ActiveCell.Value = A & "-" & B & "-" & C & "-" & D & "-" & E & "-" & F
ActiveCell.Offset(1, 0).Select
Next F
Next E
Next D
Next C
Next B
Next A
Application.ScreenUpdating = True
End Sub

All the Best
Paul



"Tom Ogilvy" wrote in message ...
Function LexNumber()
LexNumber = False
a = IIf(44 - Range("O14").Value 0, _
Application.Combin(49 - _
Range("O14").Value, 6), 0)
b = IIf(45 - Range("P14").Value 0, _
Application.Combin(49 - _
Range("P14").Value, 5), 0)
c = IIf(46 - Range("Q14").Value 0, _
Application.Combin(49 - _
Range("Q14").Value, 4), 0)
d = IIf(47 - Range("R14").Value 0, _
Application.Combin(49 - _
Range("R14").Value, 3), 0)
e = IIf(48 - Range("S14").Value 0, _
Application.Combin(49 - _
Range("S14").Value, 2), 0)
f = IIf(49 - Range("T14").Value 0, _
Application.Combin(49 - _
Range("T14").Value, 1), 0)
lNumber = Application.Combin(49, 6) _
- a - b - c - d - e - f
If lNumber 22500 And lNumber < 50000 Then
LexNumber = True
End if
End Function
--
Regards,
Tom Ogilvy



"Paul Black" wrote in message
...
Hi Everybody,

Can Somebody Please Help me with a Function.
I have a Macro that Produces 6 Number Combinations.
The First Number is Associated with Integer "A", the Second with
Integer "B" and so on.
I would like to be Able to Put a Range ( Using an "IF" Statement ) of
Lexicographic ( Combination 1 Being 01-02-03-04-05-06 ) Sequence
Numbers, so that a Combination Within that Range will be Accepted, and
a Combination Outside that Range will be Ignored.

The Excel Formula ( For a Combination of 6 Numbers in Cells O14:T14 )
is :-

=COMBIN(49,6)-IF(44-O140,COMBIN(49-O14,6),0)-IF(45-P140,COMBIN(49-P14,5),0
)-IF(46-Q140,COMBIN(49-Q14,4),0)-IF(47-R140,COMBIN(49-R14,3),0)-IF(48-S14
0,COMBIN(49-S14,2),0)-IF(49-T140,COMBIN(49-T14,1),0)

Something Like ( as a Sequential Call ) :-
If LexNumber 22500 And LexNumber < 50000 Then

Function :-
Function LexNumber()
LexNumber = False
*Code Will Go Here* Then
LexNumber = True
End Function

Any Help would be Appreciated
All the Best
Paul