Delete all content in an Excel Sheet

Hello Friends,
how is it possible to clear all the content inside an Excel Sheet?
I tried with send hotkeys but it didn’t work.
How is it possible to delete all the content in this sheet?
Movimenti.xlsx (9.5 KB)
Thank you so much friends,
Camilla. :slight_smile:

Hi Camilla,
PFA. Workflow that deletes the content of an excel sheet. I have used send hot key activity. Kindly let me know if you face any issues while executing it.
Main.xaml (6.7 KB)

Thanks and regards,
Ananthu

1 Like

Thenk you so much @Ananthu.
I tried with your workflow but it doesn’t work in my case.
Have you please got any other ideas?
Thank you so much,
Camilla :slight_smile:

Hi @CamiCat,

You can always try using a short VBA code snippet to clear the entire sheet.

See attached example: ClearAll.zip (1.6 KB)

2 Likes

Thank you so much @loginerror.
I tried to use yoour workflow but it gives me this error.


Can you please help me?
Thank you so much,
Camilla :slight_smile:

Hello,
is it possible to write a code in the assign activity to delete all the content of the written Rows?
Thank you so much,
Camilla :slight_smile:

Camilla, For the exception you got try to make the settings as mentioned below,

Exception : Programmatic access to the visual basic project..

Solution:
image

And try running it once more.

1 Like

I use the ‘write cell’ activity in an excel application scope, have the range as “A:Z” (or however many columns there are) and write the value “”. Works every time.

12 Likes

Thank you so much @KEntwistle.
If I have some columns and rows how is it possible to make a cycle over all the cells and set the content to “”?
Thank you so much,
Camilla :slight_smile:

The range “A:Z” will type over all rows in those columns. It’s the one I use because it’s more likely that I won’t know how many rows there are, than not know how many columns.

Similarly “A2:Z500” will clear that ‘rectangle’ of cells. “2:2” will clear all columns in row 2 only.

If I need to leave the headers and don’t know how many rows to clear, I over estimate how many rows there are likely to be. OR you could read just row 1 into a datatable (the headers) making sure add headers is unchecked, clear the rest of the sheet using the above method and then write the single row datatable back in (without headers - the headers will just be the superficial column0, column1 etc).

Hope this helps? The downsides are if the number of rows/columns are variable you may have to guess, but at least you’re not messing about with macros.

12 Likes

Thank you so much @KEntwistle.
I tried the solution and it worked.
Thank you so much,
Camilla :slight_smile:

2 Likes

Thank you so much @Dominic.
I tried using your solution and the Macro worked on thr Pc.
Thank you so much for your precious help.
Camilla :smiley::relaxed::relaxed:

1 Like

Hey@ KEntwistle

I have 20 rows with 4 columns need to delete, then how can I use this write range activity

1 Like

Hi @ChinnapuReddy

Assuming your data starts in A1, you could write to range “A1:D20”

1 Like