Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default looping every third row

I am trying to write a loop that will iterate every third row from row 4
to row 238. Each iteration would be as follows.

Range("C4").Select
ActiveCell.FormulaR1C1 = "=R[-1]C[0]-R[-2]C[0]"
Selection.NumberFormat = "$#,##0_);[Red]($#,##0)"
Range("C4:C4").AutoFill Destination:=Range("D4:O4")

I know I could write this in C++ with a for loop, but I'm not sure how I
would write this in VB. Any help would be great!

Jason


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default looping every third row

Untested:
for n = 4 to 238 step 3
cell(n,3).FormulaR1C1 = "=R[-1]C[0]-R[-2]C[0]"
cell(n,3).NumberFormat = "$#,##0_);[Red]($#,##0)"
Not sure what you're attempting with the next line???
Range("C4:C4").AutoFill Destination:=Range("D4:O4")
next


"Jason Hancock" wrote in message
...
I am trying to write a loop that will iterate every third row from row 4
to row 238. Each iteration would be as follows.

Range("C4").Select
ActiveCell.FormulaR1C1 = "=R[-1]C[0]-R[-2]C[0]"
Selection.NumberFormat = "$#,##0_);[Red]($#,##0)"
Range("C4:C4").AutoFill Destination:=Range("D4:O4")

I know I could write this in C++ with a for loop, but I'm not sure how I
would write this in VB. Any help would be great!

Jason


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default looping every third row

I am getting compile error: sub or function not defined on the
cell(n,3). Do I need to Dim the cell?



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default looping every third row

Change cell to Cells.



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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default looping every third row

I think it's supposed to be

Cells

instead of cell.

--
Regards

Juan Pablo González

"Jason Hancock" wrote in message
...
I am getting compile error: sub or function not defined on the
cell(n,3). Do I need to Dim the cell?



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default looping every third row

Yeah, that got it. Cells instead of cell. I should have known that
from my errors with sheet and sheets.

As for the line that had an unknown meaning:

Range("C4:C4").AutoFill Destination:=Range("D4:O4")

I'm trying to get the formula to be put in columns C through O. This
line, in a modified state, succeeded in putting dates in several cells,
however now I am getting a Runtime Error '1004'. Any ideas?




*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Reply
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
Looping David T Excel Discussion (Misc queries) 2 August 30th 06 10:51 PM
looping to End Nabeel Moeen Excel Programming 2 February 25th 04 10:52 AM
Looping Andrew Clark[_2_] Excel Programming 1 December 20th 03 05:01 PM
Looping [email protected] Excel Programming 0 October 31st 03 07:47 PM
Need Looping Help [email protected] Excel Programming 2 October 29th 03 08:11 PM


All times are GMT +1. The time now is 12:00 PM.

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

About Us

"It's about Microsoft Excel"