Delete all content in an Excel Sheet

excel
activities

#1

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:


#2

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


#3

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:


#4

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)


#5

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:


#6

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:


#7

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

Exception : Programmatic access to the visual basic project..

Solution:

And try running it once more.


#8

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.


#9

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:


#10

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.


#11

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


#12

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: