Link to home
Create AccountLog in
Avatar of srikanthv2322
srikanthv2322

asked on

Clear Cells from Specified Row in Excel

I would like to clear the spreadsheet from the specified Row at the click of a Command Button

Example:
I would like to clear from Row 13 in the Sheet1 till end, as i have my Spreadsheet heading above the Row 13 which i dont want to clear

What would be the VBScript code for the above
Avatar of Saurabh Singh Teotia
Saurabh Singh Teotia
Flag of India image


You can use the following code which will do what you are looking for...

Saurabh...
Sub cleardata()
    Dim lr As Long
    lr = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
    If lr > 13 Then Rows("14:" & lr).ClearContents



End Sub

Open in new window

You need it as VBScript or VBA for Excel?
ASKER CERTIFIED SOLUTION
Avatar of Christian de Bellefeuille
Christian de Bellefeuille
Flag of Canada image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of srikanthv2322
srikanthv2322

ASKER

Thank You