Script to Delete Rows

yvettew78

New Member
Joined
Aug 23, 2020
Messages
34
Platform
  1. Windows
  2. Web
Hi Everyone

I am after a function to include in my RESET google sheets script that deletes any rows that the user may have added after row 19. If the user needs to add a new item to the form, they can do that automatically by clicking on a button which I have assigned a script to, to make it insert a new row/item but I want it to reset to the forms original state. There are 27 possible item choices the user can choose so I can't assign a value of how many rows to delete as it will vary each time the form is used.

Can anyone help with this please?

Thank you.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Which column would hold the "extra" data that needs removing.
Maybe something like this
VBA Code:
Sub Delrow()
Dim lr As Long, r As Long
Application.ScreenUpdating = False
lr = Cells(Rows.Count, "A").End(xlUp).Row
    For r = lr To 20 Step -1
        If Range("A" & r).Value <>"" Then Rows(r).delete
    Next r
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,206
Messages
6,123,636
Members
449,109
Latest member
Sebas8956

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top