Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting everything from a worksheet

Tags:

excel

vba

I have a macro right now which adds stuff to a worksheet (text, formatting, pictures), then it prints the worksheet at my default printer, and then clears the worksheet.

This is the code I have right now where i is the number of times it enters data and 25 is the number of rows affected each time it adds data.

Range("A1", "I" & i * 25).Clear

My problem is that it clears the text, it unmerges cells and it removes all formatting but it does not delete the pictures. What do I need to do differently to delete them?

like image 1000
Tim.DeVries Avatar asked Jan 30 '26 15:01

Tim.DeVries


1 Answers

To remove pictures:

Dim s As Shape
For Each s In ActiveSheet.Shapes
    s.Delete
Next s
like image 185
Gary's Student Avatar answered Feb 03 '26 10:02

Gary's Student



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!