suzie_q
suzie_q

Reputation: 39

VBA: Delete integer number of rows starting at a certain cell

I have data with headers beginning in C9, data ranging from C10 to AT100. I need to be able to delete just some rows based on a number put in a userform, and shift the data up. So if the integer evaluated to 5, the data in rows 10 through 15 would be deleted, and the data below that would be shifted up to keep the table full.

My calculation is as follows:

Dim toDelete As Integer

Num_1 = SpinButton1.Value
Num_2 = SpinButton2.Value

toDelete = Num_1 * Num_2

If toDelete was 10, I would want to delete the 10 rows below row 9 (since those are my headers.) Thank you for any help you can give!

Upvotes: 1

Views: 81

Answers (1)

Scott Craner
Scott Craner

Reputation: 152660

Use:

Rows(10).Resize(toDelete).Delete

Upvotes: 3

Related Questions