Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Loop every 26 rows and if..

Would appeciate VBA code for a macro that does the following:

My range from Row 2 to Row 4993 has records in sets of 26 rows each.
ProceduIf Activecell (R2, Range name €śStart€ť)=0,move 16 columns left to
be at B2, write €śA/C closed€ť
Then move 16 columns right (back to column R), 26 rows down (R28) for next
record, repeat procedure

Else move down 26 rows (R28), repeat procedure
And so on until last record at R4968

Thank you,
--
Robert
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Loop every 26 rows and if..

Sub Test()
Dim irow As Long
For irow = 2 To 4968 Step 26
If Cells(irow, "R").Value = 0 Then
Cells(irow, "B").Value = "A/C closed"
Next irow
End Sub


HTH
--
AP

"Robert" a écrit dans le message de
...
Would appeciate VBA code for a macro that does the following:

My range from Row 2 to Row 4993 has records in sets of 26 rows each.
ProceduIf Activecell (R2, Range name "Start")=0,move 16 columns left to
be at B2, write "A/C closed"
Then move 16 columns right (back to column R), 26 rows down (R28) for

next
record, repeat procedure

Else move down 26 rows (R28), repeat procedure
And so on until last record at R4968

Thank you,
--
Robert



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Loop every 26 rows and if..

Thanks Ardus, but I get "Compile error:
Next without For
--
Robert



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Loop every 26 rows and if..

Hi Robert,

Try inserting:

End If

after:

Cells(irow, "B").Value = "A/C closed"



---
Regards,
Norman


"Ardus Petus" wrote in message
...
Sub Test()
Dim irow As Long
For irow = 2 To 4968 Step 26
If Cells(irow, "R").Value = 0 Then
Cells(irow, "B").Value = "A/C closed"
Next irow
End Sub


HTH
--
AP



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Loop every 26 rows and if..

Norman, yes that did it.
Thank you so much for helping again.

Ardus, once again thank you
--
Robert



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
Loop relative rows PST Excel Discussion (Misc queries) 1 May 20th 07 12:23 PM
Deleting rows loop briskbaby Excel Programming 4 October 7th 05 09:10 PM
Loop through rows using a wildcard. mthomas[_4_] Excel Programming 2 August 4th 05 03:32 PM
loop to insert rows Fergie Excel Programming 1 November 18th 04 03:48 AM
Cannot loop through rows in C# Howard Excel Programming 2 February 5th 04 03:39 PM


All times are GMT +1. The time now is 03:59 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"