Here's a UDF that appeared on this board some time ago. I take no credit whatsoever for this; I wish I could remember who wrote it to give credit where it's due (you know who you are!).
Paste it into a module. Then, if for instance you are evaluating A1 as being a prime number or not, type the formula =PRIMENUMBER(A1) into B1 or wherever, and it will return a value of True or False.
Public Function PrimeNumber(ByVal iNumber As Integer) As Boolean
Dim i As Integer
PrimeNumber = True
Select Case iNumber
Case 0
PrimeNumber = False
Exit Function
Case 1 Or 2
Exit Function
Case Else
For i = 2 To iNumber - 1
If iNumber Mod i = 0 Then
PrimeNumber = False
End If
Next
End Select
End Function
HTH
Tom Urtis
I hope Chris doesn't need to check if 9.99999999999999E307 is prime! (nt)
checks for any remainder via MOD on all numbers between it and 2 ?
awesome lateral thinking in that code
thanks Tom
:-)
haha nope, I'm just an accountant :-) (NT)
Sort of....... we have been tasked to reduce our stationery budget and I'm the main culprit via printing off reams and reams of stuff each day week month and quarter (control accounts and tax)
so I suggested rather than printing them, they are stored electronically, but my boss worried about audit trails and the lack of an ink signature
I was tryign to think of a way to save my files with unique, non-repeatable filenames or values in the file somewhere that could not be changed but proved they had been verified
I remembered somewhere about using the product of primes in generating a unique number that couldn't be reversed without a lot of number crunching on Crays....
See http://j-walk.com/ss/excel/eee/eee015.txt POWER FORMULA TECHNIQUE