ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Removing artifacts from a spreadsheet with VBA (https://www.excelbanter.com/excel-programming/441306-removing-artifacts-spreadsheet-vba.html)

Brian E McNamee

Removing artifacts from a spreadsheet with VBA
 
I copy excerpts of HTML tables into spreadsheets and get "artifacts" some of
which respond to clicking to select and then using DELETE or CUT. When the
cell/row they're in is deleted they migrate to the adjcent row/cell. How can
I identify and remove these with VBA? I've tried to "Record Macro" to see
what the genie does, but all he says is: "Selection.Delete" and that doesn't
tell me what was selected! So, it's useless to include it in my code. I
want to get rid of them because the really drag in a lot of something that
slows down processing on the sheet and fattens it considerably!
--
Brian McNamee

Paul

Removing artifacts from a spreadsheet with VBA
 

Brian, try this code:



Code:
--------------------


Sub removeShapes()
Dim sh As Shape
For Each sh In ActiveSheet.Shapes
sh.Delete
Next sh
End Sub
--------------------


--
Paul

- Paul
------------------------------------------------------------------------
Paul's Profile: 1697
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=192733

http://www.thecodecage.com/forumz


Brian E McNamee

Removing artifacts from a spreadsheet with VBA
 
Paul,

This did the trick. Thank you very much. It reduced the time it took to
process one of my speadsheets that was littlered with "shapes" from over 3
hours to ten minutes!

--
Brian McNamee


"Paul" wrote:


Brian, try this code:




Code:
--------------------



Sub removeShapes()
Dim sh As Shape
For Each sh In ActiveSheet.Shapes
sh.Delete
Next sh
End Sub


--------------------


--
Paul

- Paul
------------------------------------------------------------------------
Paul's Profile: 1697
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=192733

http://www.thecodecage.com/forumz

.



All times are GMT +1. The time now is 09:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com