View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Otto Moehrbach[_6_] Otto Moehrbach[_6_] is offline
external usenet poster
 
Posts: 201
Default Is variable an integer?

Frank
Correct me if I'm wrong but doesn't the VBA Mod function round all
numbers before it does the division? As I understand it, the VBA mod, as in
"somenumber Mod 1" will always return zero regardless of what "somenumber"
is. Thanks for your help. Otto
"Frank Kabel" wrote in message
...
Hi Otto

just to add to Bob's and Jake' suggestion why your line
MsgBox Application.WorksheetFunction.Mod(Range("D6"),1)
did produce an error.
WorksheetFunction.Mod is not supported as VBA directly implements the
MOD function. So the corret syntax would be:
MsgBox Range("D6").value mod 1

Though the other solutions are definetly better

Frank



Otto Moehrbach wrote:
Excel 2003, WinXP
My end goal is to test a cell value, via VBA, to see if it is an
integer. The worksheet Mod function works like this:
Mod(D6,1) returns a 0 if D6 is an integer.
The VBA Mod function rounds all numbers first so I can't use that.
So I used:
MsgBox Application.WorksheetFunction.Mod(Range("D6"),1)
I was hoping to get a 0 if D6 is an integer.
I got an error message that said "Object doesn't support this

method".
Where did I go wrong? Thanks for your help. Otto