Subtract 1 from Each Number in Column

  • Thread starter Thread starter ani
  • Start date Start date
A

ani

I have a column of quantities in excel and I want to subtract 1 fro
each of these numbers, unless the number is already zero. Any idea ho
to do that?

Thanks
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top