Sub KillRows()
Dim Myrange As Range
Dim NumKill As Long
Dim KillColumn As String
Dim ActiveColumn As String
Dim AC
AC = Split(ActiveCell.EntireColumn.Address(, False), ":")
ActiveColumn = AC(0)
KillColumn = InputBox("Enter Column that will be used to map rows for deletion - press Cancel to exit sub", "Row Delete Code", ActiveColumn)
If Application.CountA(Range("IV:IV")) > 0 Then
MsgBox "There are no spare columns. Macro will exit", vbCritical
Exit Sub
End If
NumKill = InputBox("Input an Integer less than 65536", "How many rows do you want to kill", Default:=15)
Set Myrange = Range(Cells(1, KillColumn), Cells(65536, KillColumn).End(xlUp))
Application.ScreenUpdating = False
If Myrange Is Nothing Then Exit Sub
With Myrange.Offset(0, 1)
.EntireColumn.Insert
.FormulaR1C1 = "=MOD(row(RC[-1])," & NumKill & ")=0"
.AutoFilter Field:=1, Criteria1:="FALSE"
If .Cells.Count > 0 Then .EntireRow.Delete
.EntireColumn.Delete
End With
Cells(1, KillColumn).Activate
Application.ScreenUpdating = True
End Sub
|