View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Problem incrementing rows

Confused,

How about this

i = 112
For Each row In Rows("1:267")
For Each cell In row.Columns("A:D")
If cell.Value = "PACK" Then
cell.Value = "PACK" & CStr(i)
End If
Next cell
i = i + 2
If i 140 Then i = 0
Next row

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"hotherps " wrote in message
...
This code almost does what I need, but I'm stuck.
When I run this each cell that matches increments by two. I want to
keep the same value for the whole row. Then drop a row and increment by
two on the next row.

Example:
(Do not want)
Pack112 Pack114 Pack116
(Do want)
Pack112 Pack112 Pack112
Pack114 Pack114 Pack114

i = 112
For Each CELL In Range("A1:DD267")
If CELL.Value = "PACK" Then
i = i + 2

CELL.Value = "PACK" & CStr(i)

If i 140 Then i = 0

End If
Next CELL

Thanks



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