bloubul
Member
Hi All
I have the following macro, which in itself is a brilliant piece of work.
What I would like to know is, will it be possible to make a few changes to the macro so that it still deletes every nth row but only “X” number of cells to the left as indicated in yellow, the range will get longer as more draws are added. All the current message boxes must still be displayed. See the attached spreadsheet.
Here is the macro:
Option Explicit
Sub DeleteRow()
Dim EndRow, CheckRows, I, StartRow, StepRow
StartRow = Application.InputBox _
("Enter which row is the first to be removed." & Chr(10), _
"Rows to delete - Start point", , , , , , 1)
If TypeName(StartRow) = "Boolean" Then
Exit Sub
End If
StepRow = Application.InputBox _
("Enter increment of n-th row to delete," & Chr(10) & _
"i.e. 2 = every other, 3 every third?" & Chr(10), _
"Rows to delete - Step", , , , , , 1)
If TypeName(StepRow) = "Boolean" Or StepRow <= 1 Then
MsgBox "Sorry, do not remove every row with this code."
Exit Sub
End If
EndRow = Application.InputBox _
("Enter which row is the last to be removed." & Chr(10), _
"Rows to delete - End point", , , , , , 1)
If TypeName(EndRow) = "Boolean" Then
Exit Sub
End If
CheckRows = MsgBox("You want to remove rows in steps of " & StepRow _
& ", starting with row " & StartRow & " and ending with row " _
& EndRow & ". Correct?", vbYesNo, "Verify data!")
If CheckRows = vbYes Then
I = StartRow
Do Until I > EndRow
Rows(I).Select
Selection.Delete Shift:=xlUp
I = I + StepRow - 1
Loop
Else
End If
Application.Goto Reference:="R1C1"
End Sub
Here are the link:
https://www.mediafire.com/file/cdq9198e5ayix66/Book1.xlsx/file
BlouBul
I have the following macro, which in itself is a brilliant piece of work.
What I would like to know is, will it be possible to make a few changes to the macro so that it still deletes every nth row but only “X” number of cells to the left as indicated in yellow, the range will get longer as more draws are added. All the current message boxes must still be displayed. See the attached spreadsheet.
Here is the macro:
Option Explicit
Sub DeleteRow()
Dim EndRow, CheckRows, I, StartRow, StepRow
StartRow = Application.InputBox _
("Enter which row is the first to be removed." & Chr(10), _
"Rows to delete - Start point", , , , , , 1)
If TypeName(StartRow) = "Boolean" Then
Exit Sub
End If
StepRow = Application.InputBox _
("Enter increment of n-th row to delete," & Chr(10) & _
"i.e. 2 = every other, 3 every third?" & Chr(10), _
"Rows to delete - Step", , , , , , 1)
If TypeName(StepRow) = "Boolean" Or StepRow <= 1 Then
MsgBox "Sorry, do not remove every row with this code."
Exit Sub
End If
EndRow = Application.InputBox _
("Enter which row is the last to be removed." & Chr(10), _
"Rows to delete - End point", , , , , , 1)
If TypeName(EndRow) = "Boolean" Then
Exit Sub
End If
CheckRows = MsgBox("You want to remove rows in steps of " & StepRow _
& ", starting with row " & StartRow & " and ending with row " _
& EndRow & ". Correct?", vbYesNo, "Verify data!")
If CheckRows = vbYes Then
I = StartRow
Do Until I > EndRow
Rows(I).Select
Selection.Delete Shift:=xlUp
I = I + StepRow - 1
Loop
Else
End If
Application.Goto Reference:="R1C1"
End Sub
Here are the link:
https://www.mediafire.com/file/cdq9198e5ayix66/Book1.xlsx/file
BlouBul