incrementing cells withina formula in VB

P

Paul

Hi,


Do While Range("b11").Value > 0
Range("e15").Value = Range("e15").Value + Range("c15").Value
Range("e16").Value = Range("e16").Value + Range("c16").Value
Range("e17").Value = Range("e17").Value + Range("c17").Value
.........>>>
Range("e40").Value = Range("e40").Value + Range("c40").Value
Range("b11").Value = Range("b11").Value - 1
End

Loop

Any help appreciated. I'm trying to get a spreadsheet to check a list
of values if a condition is met. For example, B11 = 40 in this
instance. While this works as is, i would like to clean it up by
perhaps having a single line formula that would increment the row
values as it goes through the loop. along the lines of:

Range("b12").Value = "55"
Do While Range("b11").Value > 0
Range("b12").Value = Range("b12").Value - Range("b11").Value
Range("e[B11]").Value = Range("e[B11]").Value +
Range("c[B11]").").Value
Range("b11").Value = Range("b11").Value - 1
End

Loop
Thanks

Paul
 
F

Frank Kabel

Hi Paul
not compelte sure but try
sub foo()
dim row_index as long
dim lastrow as long
with activesheet
lastrow=.range("B11").value
for row_index = lastrow to 1 step -1
.cells(row_index,"E").value=.cells(row_index,"E").value + _
.cells(row_index,"C").value
next
end with
end sub
 

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

Top