View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.newusers
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default How do I add 1 to a number in column b

Assuming the cells in the range contain either whole numbers or, if floating
point numbers are used, the decimal point for the system is a "dot", then
this statement...

c.Value = Left(c, InStr(c, " ") - 1) + 1 & " years"

can be replaced with this slightly simpler one...

c.Value = Val(c.Value) + 1 & " years"

--
Rick (MVP - Excel)


"Don Guillett" wrote in message
...
A macro solution
Sub addnumbertotext()
'=LEFT(J5,FIND(" ",J5)-1)+1& " years"
For Each c In Range("b2:b22") 'Selection
c.Value = Left(c, InStr(c, " ") - 1) + 1 & " years"

Next c
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...
A formula approach
=LEFT(J5,FIND(" ",J5)-1)+1& " years"

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"diana" wrote in message
...
I have a spreadsheet in which column b refers to the number of years of
safe
driving. ie "22 years". How do I add 1 to each cell in column B?