View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Earl Kiosterud[_4_] Earl Kiosterud[_4_] is offline
external usenet poster
 
Posts: 25
Default How to increment number using vb script

Lillian,

Dim a As Long
Dim MyCell As Range
Set MyCell = Range("C2") ' starting cell
a = 2000 ' starting value
Do While MyCell < "" ' stop on empty cell
MyCell = MyCell + a ' add a
Set MyCell = MyCell.Offset(1, 0) ' move down
a = a + 2000 ' increment a
Loop

this presumes the original values are all 2. It doesn't replace, it adds.

--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

"Lillian" wrote in message
...
I have one excel spreed sheet on columnA one row A1 has "000002", on the
3rd
charactor I need to change to 2 for second row as "002002", then third row
will be as "004002", I need to increment 2 from the previous row until to
the
end of row as"998002", how to run with the macro.
000002
002002
004002
006002
..........
998002

Thank you so much.