How can I remove the last two excel rows using Excel activities?

Hello, I want to delete the last two rows from an excel sheet. How can I do this using Excel activities? I saw a lot of examples, but with data table and other acitivities.

@adrianab.98

Use a for each excel row activity and then give the sheet you want to read…

Excel.Sheet("Name").RowCount would give you the count of rows in excel…

Use a if condition where you can use a counter and check if counter value is equal to rowcount or rowcount-1 and if yes use deletw row activity

Counter should be incremented in every iteration so use counter = counter +1

I tried this and it looks that this activity get row by row until it arrives at the last row. When I have many rows it appears like the activity does nothing, but on small excels it works.

@adrianab.98

Then donot use for loop instead to delete row you can pass the row number to delete which would be the count of rows and count of rows - 1 …which you will get from the same count function above…then no loop is there and only two delete row activities

Cheers

I got it, I used Find First/Last Data Row

1 Like