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

#### Ironman

##### Well-known Member
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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
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``````

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:

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``````

Fantastic, thanks a lot Peter, works perfectly!

Thanks also EFAN for your help.

Cheers.

Might have marked the wrong one as solution but (shrug) happy to help

Ah just seen in the original text, sorry

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``````

Replies
61
Views
3K
Replies
9
Views
363
Replies
14
Views
714
Replies
3
Views
75
Replies
9
Views
556

1,203,060
Messages
6,053,305
Members
444,651
Latest member
markkuznetsov1

### 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.

### Which adblocker are you using?

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

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