Insert text every 7th row, starting and ending in a specific row

Ironman

Well-known Member
Joined
Jan 31, 2004
Messages
1,069
Office Version
  1. 365
Platform
  1. Windows
Hi

I'd be grateful for some code I can run that will insert "WEEK TOTAL = " (without the commas, double underlined and with a space after the "=") in every 7th row of Col F in sheet 'Training 1981-1997', with the first in F2469 and the last in F6207.

Many thanks!
 
Last edited:

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hey Ironman
This should do the trick
VBA Code:
Sub Every7thRow()
    Dim i As Integer
    Dim Last As Boolean
    For i = 2469 To 6207
        If i < 2193 Then Last = True
        ThisWorkbook.Sheets("Training 1981-1997").Cells(i, 6).Value = "WEEK TOTAL = "
        i = i + 7
        If i = Last Then Exit For
    Next i
End Sub
 
Upvote 0
Many thanks EFAN!

Before I run it, is there any chance you could add a line to the code that will double-underline the text please?

Thanks again!

Edit - I've just test run it and it works great when I changed "i = i + 7" to "i = i + 6".
 
Last edited:
Upvote 0
What about ..

VBA Code:
Sub Every7()
  Dim i As Long
  
  For i = 2469 To 6207 Step 7
    With Sheets("Training 1981-1997").Range("F" & i)
      .Value = "WEEK TOTAL = "
      .Font.Underline = xlUnderlineStyleDouble
    End With
  Next i
End Sub
 
Upvote 0
Solution
Fantastic, thanks a lot Peter, works perfectly!

Thanks also EFAN for your help.
 
Upvote 0
Might have marked the wrong one as solution but (shrug) happy to help
 
Upvote 0
Try this:
VBA Code:
Sub My_Sub()
'Modified 2/6/2022  7:20:50 AM  EST
Application.ScreenUpdating = False
Dim i As Long

For i = 2469 To 6207 Step 7
    With Sheets("Training 1981-1997")
        .Cells(i, "F").Value = "WEEK TOTAL = "
        .Cells(i, "F").Font.Underline = xlUnderlineStyleDouble
       End With
Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,523
Messages
6,125,323
Members
449,218
Latest member
Excel Master

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