I'm currently using:
...but I find it only works if the first row is within the same number of rows specified in RowsBetween.
For example, if RowsBetween = 2, and I select a range where the top row is greater than or equal to 3, it will not work properly, but instead select only one row; the row directly under the first row is selected in the desired range; the column count highlighted would be correct; just not the desired range of rows. Any ideas?
Code:
Sub SelectEveryNthRow()
ColsSelection = Selection.Columns.Count
RowsSelection = Selection.Rows.Count
RowsBetween = 2
Diff = Selection.Row - 1
Selection.Resize(RowsSelection, 1).Select
Set FinalRange = Selection. _
Offset(RowsBetween - 1, 0).Resize(1, ColsSelection)
For Each xCell In Selection
If xCell.Row Mod RowsBetween = Diff Then
Set FinalRange = Application.Union _
(FinalRange, xCell.Resize(1, ColsSelection))
End If
Next xCell
FinalRange.Select
End Sub
...but I find it only works if the first row is within the same number of rows specified in RowsBetween.
For example, if RowsBetween = 2, and I select a range where the top row is greater than or equal to 3, it will not work properly, but instead select only one row; the row directly under the first row is selected in the desired range; the column count highlighted would be correct; just not the desired range of rows. Any ideas?