View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Subtract 1 from Each Number in Column

for each cell in selection
if isnumeric(cell.Value) then
if cell.Value 1 then
if not cell.Hasformula then
cell.Value = cell.Value - 1
end if
end if
End if
Next


or

set rng = Selection.SpecialCells(xlConstants,xlNumbers)
for cell in rng
if cell.Value 0 then
cell.Value = Cell.Value - 1
end if
Next

--
Regards,
Tom Ogilvy

"ani " wrote in message
...
I have a column of quantities in excel and I want to subtract 1 from
each of these numbers, unless the number is already zero. Any idea how
to do that?

Thanks!


---
Message posted from http://www.ExcelForum.com/