Forum Discussion

ushbar's avatar
ushbar
Copper Contributor
Oct 28, 2020
Solved

Select every N-th row and replace column values

Hi,    I'm new to VBA and macro so I need help with a script/code that can select every 18th-21th row and replace column "I" with the following values:  Paranøtter Pekannøtter Pistasjnøtt...
  • HansVogelaar's avatar
    Oct 28, 2020

     

    Sub EditRows()
        Dim r As Long
        Dim m As Long
        Application.ScreenUpdating = False
        m = Range("A" & Rows.Count).End(xlUp).Row
        For r = 19 To m Step 21
            Range("I" & r).Value = "Paranøtter"
            Range("I" & r + 1).Value = "Pekannøtter"
            Range("I" & r + 2).Value = "Pistasjnøtter"
            Range("I" & r + 3).Value = "Valnøtter"
            Range("L" & r).Resize(4, 4).ClearContents
        Next r
        Application.CutCopyMode = False
        Application.ScreenUpdating = True
    End Sub

    ushbar 

Resources