How to copy and paste specific range n times? Used this thread to copy and paste the range I want. Now I want to be able to delete these ranges starting from the bottom n times.
Mostly stuck on how to determine the range it is I need to clear.
CodePudding user response:
with this code you can chose how many times you will delete the range (n), and how many rows will be deleted each time (row_number)
Dim ws As Worksheet: Set ws = Sheets("Sheet1")
Dim n as Integer
Dim i as Integer
n = insert_number_of_times
row_number = number_of_rows_to_delete_each_time
i = 1
while i<=n
last_row = ws.Range("A10000").End(xlUp).Row
first_row = last_row - row_number
ws.Range("A" & first_row & ":X" & last_row).ClearContents 'X = column reference
i = i 1
loop