View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Check if a value is an integer using VBA code

Sub MakeArray()
Dim arr() as Long
Dim i as Long
redim arr(1 to selection.count)
i = 0
for each cell in selection
i = i + 1
arr(i) = 0
if isnumeric(cell) then
if int(cell) = cell then
if int(cell) = 0 then
arr(i) = cell
end if
end if
end if
Next
End sub

--
Regards,
Tom Ogilvy

"Rayo K" wrote:

I know I should be able ot do this but I'm drawing a blank and nothing seems
to be working. I want to check a series of user entered values in a vertical
range, see if they are integers, and place them in a 1D integer array. If
they are not postive integers, the array values will be set to zero ( the
range values can remain whatever they are).

How can I do this?