I don't know how to write modules yet, so I downloaded the one below. It checks to see if a number is a prime. It's cool and works, except any time that a 1 comes up. When I referrence a cell (B2 for example)that's value =1, with =isprime(B2), then I recieve "# value" as a result. This messes up the rest of my spreadsheet.![]()
![]()
Function IsPrime(ByRef rngVal As Range) As Variant Dim ValPrime As Boolean Dim x As Long Dim ValGCD As Double Dim Val As Double Val = rngVal.Value If Val = 1 Or Val < 0 Or Val <> Int(Val) Or IsEmpty(rngVal) = True Then IsPrime = "#VALUE" Exit Function End If ValPrime = True For x = 2 To Val - 1 If Val / x = Int(Val / x) Then ValPrime = False IsPrime = ValPrime Exit Function End If Next x IsPrime = ValPrime End Function
Can someone pleace help me with this?
Bookmarks