LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 394
Default Count Specific Total Numbers from a Set

Hi everyone,

I am trying to count the total number of combinations that contain
0,1,2,3,4,5 and 6 Prime Numbers in a 649 Lotto.
I am having trouble putting the code together.
I am trying to use a Select Case construct. I am trying to do it this
way because there are other sets of numbers that I would like to test,
this way, all I will have to do is change the numbers in the Select
Case to those that I want.
This is what I have so far :-

Option Explicit
Option Base 1

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

Sub Prime()
Dim nVal(6) As Double
Dim n As Integer

For n = 0 To 6
nVal(n) = 0
Next n

For A = 1 To 44
For B = A + 1 To 45
For C = B + 1 To 46
For D = C + 1 To 47
For E = D + 1 To 48
For F = E + 1 To 49

If nVal = 0 Then nVal(0) = nVal(0) + 1
If nVal = 1 Then nVal(1) = nVal(1) + 1
If nVal = 2 Then nVal(2) = nVal(2) + 1
If nVal = 3 Then nVal(3) = nVal(3) + 1
If nVal = 4 Then nVal(4) = nVal(4) + 1
If nVal = 5 Then nVal(5) = nVal(5) + 1
If nVal = 6 Then nVal(6) = nVal(6) + 1

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

Range("A1").Select

For n = 0 To 6
ActiveCell.Offset(0, 0).Value = n
ActiveCell.Offset(0, 1).Value = Format(nVal(n), "#,0")
ActiveCell.Offset(1, 0).Select
Next n

End Sub

Private Function nVal() As Integer

Select Case A
Case 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47
nVal = nVal + 1
End Select
Select Case B
Case 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47
nVal = nVal + 1
End Select
Select Case C
Case 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47
nVal = nVal + 1
End Select
Select Case D
Case 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47
nVal = nVal + 1
End Select
Select Case E
Case 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47
nVal = nVal + 1
End Select
Select Case F
Case 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47
nVal = nVal + 1
End Select

End Function

Any help will be greatly appreciated.
Thanks in Advance.
All the Best.
Paul

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
which numbers add up to a specific total esilverb Excel Worksheet Functions 2 January 27th 09 09:19 PM
How to obtain a total count of two columns for a specific product Jennifer Excel Worksheet Functions 4 April 13th 08 03:51 PM
How do i count numbers and letters to find a total count of all Linda Excel Worksheet Functions 4 November 10th 05 04:51 PM
Count and Sum Total occurrances of two specific numbers Sam via OfficeKB.com Excel Worksheet Functions 10 March 29th 05 08:13 PM
How do I add a range of numbers to sum a specific total? SJoshi Excel Worksheet Functions 3 February 15th 05 01:16 PM


All times are GMT +1. The time now is 06:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"