there is a little correction in my code
'---------------
Dim ArrDevisors()

Sub BlaBlaBlaBla()
   ' siti Vi / bluewater, indonesia / 7 May 2010
   Dim MyCell As Range
   Dim isPrima As String, n As Long
   Set MyCell = Selection
   isPrima = IsPrimeNumber(MyCell.Value)
   MyCell(1, 4) = "Result:"
   MyCell(1, 5) = isPrima
   If isPrima = "NON-PRIMA" Then
      For n = 1 To UBound(ArrDevisors)
      MyCell(1 + n, 5) = ArrDevisors(n)
      Next n
   End If
End Sub

Private Function IsPrimeNumber(aNumber As Long) As String
   ' siti Vi / bluewater, indonesia /14 Dec 2005
   Dim AreYou As Boolean
   Dim Devisor As Long
   Dim i As Long
   AreYou = True
   For Devisor = 2 To aNumber - 1
      If aNumber Mod Devisor = 0 Then
         AreYou = False
         i = i + 1: ReDim Preserve ArrDevisors(1 To i)
         ArrDevisors(i) = Devisor
      End If
   Next
   If aNumber = 0 Then AreYou = False
   IsPrimeNumber = IIf(AreYou, "PRIMA", "NON-PRIMA")
End Function
'-------------


On May 7, 12:53 pm, L- Van <elvan.bys...@gmail.com> wrote:
> hi all,
> im new member in this group..
> I want to find a number of non-prime numbers.. (please see attachment)
>
> example
>   READ 45
>
> RESULT NON-PRIMA
> 3
> 5
> 9
> 15
> …
> i read the number 15
> the result will be NON-PRIMA and the below cell (optional) will create a
> number that can be divide by *read number*
>
> Thanks for all of ur attention
> L-van

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 6,800 subscribers worldwide and receive many nice notes about the 
learning and support from the group.Let friends and co-workers know they can 
subscribe to group at http://groups.google.com/group/excel-macros/subscribe

Reply via email to