RFGNaper
asked on
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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).R
'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