Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - Remove Shapes and Cell Contents

Hello;

I have an Excel spreadsheet which I use to import images and creat
sort of a product catalog. It's working great.

However, I'm unable to come up with code that works fo
clearing/resetting the page. I've tried 3 or 4 different ways withou
any success.

What I need to do is clear all cell contents and shapes (images) withi
every column but "A". Anybody have a code sample that would do this??

Thanks in advance for your help. I appreciate it!

Ric

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Excel VBA - Remove Shapes and Cell Contents

Rick: Try the following routine. It assumes that row 1 of the worksheet is
the header row of a list, so it does not clear anything in row 1, but you
should be able to modify it however you want.

Public Sub ClearData()
Dim rngDataArea As Range
Dim shprng As ShapeRange
Dim shpPicture As Shape

'Set an object reference to the data area to be cleared.
'Assume row 1 is the header of a list, so extend the range
'from cell $B$2 to the lower right corner cell on the worksheet.
With ActiveSheet.UsedRange
Set rngDataArea = .Offset(1, 1) _
.Resize(.Rows.Count - 1, .Columns.Count - 1)
End With

'Clear the data area of values, formulas, comments, and notes.
'Add or remove any methods you want or don't want.
With rngDataArea
.ClearContents
.ClearComments
.ClearNotes
End With

'Select and delete all objects (pictures, drawing objects, etc.)
'where the top left corner cell is in the data area.
'See the Shapes Collection Object in Microsoft Excel Visual Basic Help.
For Each shpPicture In ActiveSheet.Shapes
If Not (Intersect(shpPicture.TopLeftCell, rngDataArea) Is Nothing) _
Then
'Shape is in the data area to be cleared.
shpPicture.Delete
End If
Next shpPicture
End Sub

--
Regards,
Bill


"rick6823 " wrote in message
...
Hello;

I have an Excel spreadsheet which I use to import images and create
sort of a product catalog. It's working great.

However, I'm unable to come up with code that works for
clearing/resetting the page. I've tried 3 or 4 different ways without
any success.

What I need to do is clear all cell contents and shapes (images) within
every column but "A". Anybody have a code sample that would do this??

Thanks in advance for your help. I appreciate it!

Rick


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to remove shading of shapes in Excel 2007 (with an .xls workbo Fuzzy New Users to Excel 0 September 13th 07 04:32 AM
Macro to remove last 4 characters from the contents of a cell. akkrug New Users to Excel 1 April 19th 07 07:52 PM
how to copy contents of a cell and remove any brackets ( AND ) ? jonny Excel Discussion (Misc queries) 4 January 28th 07 07:50 PM
When drawing shapes in excel the shapes keep disappearing Tape Excel Discussion (Misc queries) 1 October 6th 06 04:23 PM
Macro to remove contents of cell and move all other contents up one row adw223 Excel Discussion (Misc queries) 1 July 1st 05 03:57 PM


All times are GMT +1. The time now is 02:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"