View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Nigel Brown[_2_] Nigel Brown[_2_] is offline
external usenet poster
 
Posts: 18
Default Newbie. Please help me find a loop solution

I am trying to calculate a value for a cell and at the same time store
the previous cell value for the next calculation. The following code
works, but
I need to find a way to loop this until column AN and row 3000. I know
there must be a better solution than how my code works and would be
very greatful if someone can point me in the right direction.

Sub test()
Dim temp As Single
Dim temp2 As Single

temp = Range("m2").Value
Range("m2").Value = Range("j2").Value - temp
temp2 = Range("n2").Value
Range("n2").Value = temp - temp2
temp = Range("o2").Value
Range("o2").Value = temp2 - temp
temp2 = Range("p2").Value
Range("p2").Value = temp2 - temp

End Sub

I know there must be a better solution than how my code works and
would be very greatful if someone can point me in the right direction.

Nigel Brown