Hi
The code runs fine for me.
I would amend it slightly to switch off screen updating, and to clear the contents of column J before copying the new data range to J1.
Amended code shown below
Private Sub CommandButton1_Click()
'Sub SelectEveryNthCell()
Dim rRange As Range
Dim rEveryNth As Range
Dim lRow As Long
Application.ScreenUpdating = False
With Sheet1
Set rRange = .Range("C1", .Cells(.Rows.Count, "C").End(xlUp))
End With
For lRow = 1 To rRange.Rows.Count Step Range("a1").Value
If lRow = 1 Then
Set rEveryNth = rRange(lRow, 1)
Else
Set rEveryNth = Union(rRange(lRow, 1), rEveryNth)
End If
Next lRow
ActiveSheet.Columns("J:J").ClearContents
Application.Goto rEveryNth
Selection.Copy
ActiveSheet.Range("j1").Select
Selection.PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
ActiveSheet.Range("A1").Activate
Application.CutCopyMode = False
Application.ScreenUpdating = True
'http://www.ozgrid.com/forum/showthread.php?p=111223
'http://www.ozgrid.com/forum/showthread.php?t=91759
End Sub
Bookmarks