Clear an Excel sheet using VB.Net

I have added a "clear" button to an excel sheet and I need the VB.Net code to clear the contents of the entire sheet, minus the column headings (1 line).  The ending cell will constantly be changing each time the user uses the "clear" button.
RFGNaperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAelbrechtCommented:
i'm going to suppose you already figured out how to select the worksheet you want to do this on.

with .worksheet
    .Rows("2:2").Select
    .Range(Selection, Selection.End(xlDown)).Select
    .Selection.ClearContents
end with

this clears the complete worksheet except for the first row.

cheers,
Andy

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bruintjeCommented:
Hello RFGNaper,

if there is a continuous column like A or B you can get do it like

assuming you already have your variables declared

'this will give you the last row
intRowCount = mySheet.[A1].End(xlDown).Row
'this will clear all cells in the sheet except the first
mySheet.Range("A2:Z" & intRowCount).Clear ' Z is you last column

hope this helps a bit
bruintje
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.