Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default Data Validation Lost After Clearing All Shapes

I'm trying to delete all shapes on a sheet which works using the below code,
but a problem I'm having is that any validation list on the same sheet is
also deleted, and once delete validation lists will NOT appear on that same
sheet again even after restarting excel.

Does anyone know how to either clear all shapes but NOT validation lists, or
have any knowledge about why this occurs and why you then can't add a new
validation list (If I goto data validation the list settings are correct
and reference the list named range - doing the same on another tab works
correctly).

For Each oShape In Sheets("Sheet1").Shapes
oShape.Delete
Next oShape
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default Data Validation Lost After Clearing All Shapes

You could try using the drawingobjects collection instead.
It doesn't *seem* to include the validation drop-downs.

For Each drw In Sheets("Sheet1").DrawingObjects
....
Next drw


Tim

"Shawn" wrote in message
...
I'm trying to delete all shapes on a sheet which works using the below
code,
but a problem I'm having is that any validation list on the same sheet is
also deleted, and once delete validation lists will NOT appear on that
same
sheet again even after restarting excel.

Does anyone know how to either clear all shapes but NOT validation lists,
or
have any knowledge about why this occurs and why you then can't add a new
validation list (If I goto data validation the list settings are correct
and reference the list named range - doing the same on another tab works
correctly).

For Each oShape In Sheets("Sheet1").Shapes
oShape.Delete
Next oShape



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default Data Validation Lost After Clearing All Shapes

Good suggestion, but it ended up giving me an error (Delete method of picture
class failed - possible it's not .Delete). I figured out that the following
works. Strange part is that I still can't enter validation lists on the sheet
I used the other code on unless I create a new sheet or workbook.

For Each oShape In Sheets("Sheet1").Shapes
If oShape.Type = msoPicture Then oShape.Delete
Next oShape

"Tim Williams" wrote:

You could try using the drawingobjects collection instead.
It doesn't *seem* to include the validation drop-downs.

For Each drw In Sheets("Sheet1").DrawingObjects
....
Next drw


Tim

"Shawn" wrote in message
...
I'm trying to delete all shapes on a sheet which works using the below
code,
but a problem I'm having is that any validation list on the same sheet is
also deleted, and once delete validation lists will NOT appear on that
same
sheet again even after restarting excel.

Does anyone know how to either clear all shapes but NOT validation lists,
or
have any knowledge about why this occurs and why you then can't add a new
validation list (If I goto data validation the list settings are correct
and reference the list named range - doing the same on another tab works
correctly).

For Each oShape In Sheets("Sheet1").Shapes
oShape.Delete
Next oShape




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Data Validation Lost After Clearing All Shapes

How about:

Sub test()
Dim oshape As Shape
Dim testIt As Boolean
'
For Each oshape In Sheets("Sheet1").Shapes
On Error Resume Next ' Non drop-downs cause an error two lines down!
testIt = False
testIt = oshape.FormControlType = xlDropDown
If (Not testIt) Then oshape.Delete
Next oshape
End Sub

HTH,

Eric

"Shawn" wrote:

I'm trying to delete all shapes on a sheet which works using the below code,
but a problem I'm having is that any validation list on the same sheet is
also deleted, and once delete validation lists will NOT appear on that same
sheet again even after restarting excel.

Does anyone know how to either clear all shapes but NOT validation lists, or
have any knowledge about why this occurs and why you then can't add a new
validation list (If I goto data validation the list settings are correct
and reference the list named range - doing the same on another tab works
correctly).

For Each oShape In Sheets("Sheet1").Shapes
oShape.Delete
Next oShape

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
Deleting shapes with VB deletes cell validation as well. EH? Brettjg Excel Programming 12 March 23rd 09 03:18 PM
Used drawing colors in shapes....lost default colors for "Fill Col Lai704 Excel Discussion (Misc queries) 1 August 20th 08 04:45 AM
I have lost the in cell drop down in validation Stan Lawson Excel Worksheet Functions 2 February 28th 06 12:06 AM
Validation lost on advanced filter copy Andy Excel Programming 1 April 26th 04 02:15 PM
Excel VBA - Clearing Shapes and Cell Contents Rick[_19_] Excel Programming 2 April 10th 04 12:26 AM


All times are GMT +1. The time now is 06:41 PM.

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

About Us

"It's about Microsoft Excel"