Ask a Question

How to delete all rows from excel

jasmeenkaur27
Contributor

How to delete all rows from excel

Hi

 

I have to delete all rows from excel before executing another function.

1 REPLY 1
shankar_r
Community Hero

Hi,

 

You can do like below,

 

excelObject = Sys.OleObject("Excel.Application");
excelWorkbookObj = excelObject.Workbooks.Open(<strexcelFileName>);
excelMainSheet = excelWorkbookObj.Sheets.Item("<Your sheet name>");
excelMainSheet.UsedRange.ClearContents //this will only clear contents
excelMainSheet.Cells.Clear //this will clear everything

 


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

cancel
Showing results for 
Search instead for 
Did you mean: