Thread: Multiples
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_5_] Bob Phillips[_5_] is offline
external usenet poster
 
Posts: 620
Default Multiples

You're welcome Greg, it's what it's for.

Bob


"Greg Glynn" wrote in message
...
Here's a simple way (Is stole Bob Philips' MOD test line .. Thanks Bob)

Sub ShowMults()
TestNum = 36
Results = ""
For x = 1 To TestNum
If TestNum Mod x = 0 Then
Foundcount = Foundcount + 1
If Foundcount 1 Then Results = Results & ", " & x Else: Results = x
End If
Next x
MsgBox ("Found " & Foundcount & " Multiples of " & TestNum & vbCrLf &
Results)
End Sub


wrote in message
om...
Is there a way function in VBA that allows you to calcualte the
multiple of a number. That is, if the variable = 36, I want to
calculate all nine multiples:

M1=1 (1*36=36)
M2=2 (2*18=36)
M3=3 (3*12=36)
M4=4
M5=6
M6=9
M7=12
M8=18
M9=36

Thanks

TS