Pericles Faliagas
Pericles Faliagas

Reputation: 636

How to create a loop inside a loop vba

I am trying to create this loop inside the loop so as to print inside the cells in the below range -> Week i where i is from 1 to 6 and it raises by one each time we move to a cell down...

So, in this case, for D2 I want Week 1, For D3 Week 2 etc.. Any ideas? I appreciate your time!

 Sub INPUT()
        Sheets("1").Select 
        For Each cell In range("D2:D7")
        For i = 1 To 6
        cell.Value = "Week +" & i
        i = i + 1
        Next i
        Next cell
End Sub

Upvotes: 1

Views: 483

Answers (1)

Scott Craner
Scott Craner

Reputation: 152505

You only need the one loop:

Sub INPT()
    With Sheets("1")
        i = 1
        For Each cell In .Range("D2:D7")
            cell.Value = "Week +" & i
            i = i + 1
        Next cell
    End With
End Sub

Upvotes: 2

Related Questions