Hi guys,
I'm new here and very new to VBA (just know the bare basics) -- nice to meet you!
I wanted to create a code to insert a blank every 10th row and after copying and pasting bits and pieces of other people's codes, I finally got the code to work...but I'm not sure how this is working and would love to fully understand how this is actually working. I'm completely lost from the "i = 1" part (bolded below). What is the role of i and j, and why/how does the "Do" function play a role in this code? Thank you in advance for your help!
Sub InsertRowEvery10thRow()
Dim i As Long
Dim lr As Long
Dim j As Long
lr = Range("A" & Rows.Count).End(xlUp).Row
i = 1
j = 1
Do
If j = 11 Then
Rows(i).Insert Shift:=xlDown
j = 1
Else
j = j + 1
End If
i = i + 1
Loop While i <> lr
End Sub
I'm new here and very new to VBA (just know the bare basics) -- nice to meet you!
I wanted to create a code to insert a blank every 10th row and after copying and pasting bits and pieces of other people's codes, I finally got the code to work...but I'm not sure how this is working and would love to fully understand how this is actually working. I'm completely lost from the "i = 1" part (bolded below). What is the role of i and j, and why/how does the "Do" function play a role in this code? Thank you in advance for your help!
Sub InsertRowEvery10thRow()
Dim i As Long
Dim lr As Long
Dim j As Long
lr = Range("A" & Rows.Count).End(xlUp).Row
i = 1
j = 1
Do
If j = 11 Then
Rows(i).Insert Shift:=xlDown
j = 1
Else
j = j + 1
End If
i = i + 1
Loop While i <> lr
End Sub