LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Counter variable in For Loop

Howdy,
I'm trying to get a relatively simple macro that will give me a
difference between values moving from the first and last values back to
the middle. ie A2-A200, A3-A199, A4-A198, et al.
This is the code that I've written.

Sub CycleDiff()
J = 300
Range("F2").Select
For Ct = 1 To 150
ActiveCell.FormulaR1C1 = "=(RC[-4])-(R[" & J & "]C[-4])"
ActiveCell.Offset(1, 0).Select
J = J - 1
Next Ct
End Sub

The problem is that the first cell creates the correct formula and the
offset moves it to the next cell down, but it is always subtracting
from B302 instead of moving up to B301, B300, etc. Is there something
wrong with my counter that it's always resetting to the original
variable instead of staying in the loop?
Thanks in advance,
AM

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counter variable and a multiplier LenS Excel Discussion (Misc queries) 1 February 23rd 07 11:50 AM
Should I use Do-While loop for my record counter? excelnut1954 Excel Programming 0 March 24th 06 09:25 PM
Counter & Loop tutorial website Jill[_7_] Excel Programming 1 June 25th 04 02:12 AM
On Screen Loop Counter simoncohen Excel Programming 3 April 2nd 04 10:36 AM
variable counter/total Carole Excel Programming 1 October 20th 03 07:23 AM


All times are GMT +1. The time now is 06:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"