stuck on code to loop through every nth row cells

rcr1991

New Member
Joined
Oct 26, 2005
Messages
37
I am a total coding amateur so please don't be too harsh--this is my first time posting my rudimentary code.

Problem is outlined below:

Sub Macro1()
LastRow = Cells(Rows.Count, 2).End(xlUp).Row
RptRows = LastRow / 5
Rows("5:5").Select
For x_rpts = 1 To RptRows

'now i need to start at current row, always row 5, and add 4 to row number, go to that row, select it, and make it bold
'then repeat from current row, go down four rows and repeat RptRows # times--the looping actually works--just stuck on the code to get row number, add 4 to it and move on


Next x_rpts
End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Using Step 5 to make every 5th line bold..

Code:
Public Sub MakeBold()
For Rw = 5 To Cells(65536, 2).End(xlUp).Row Step 5
    Cells(Rw, 1).EntireRow.Font.Bold = True
Next Rw
End Sub

HINT: Step 5 tells the "For" to loop by every 5th iteration. Which , in this case would mean Rw = 5,10,15,20....etc..


FURTHER EXAMPLES...(of using Step)

Code:
Public Sub CountUp()
For lp = 1 To 10 Step 2
    MsgBox lp
Next lp
End Sub

Public Sub CountDown()
For lp = 10 To 1 Step -2
    MsgBox lp
Next lp
End Sub
 
Upvote 0

Forum statistics

Threads
1,207,423
Messages
6,078,443
Members
446,338
Latest member
AliB

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top