PC Review


Reply
Thread Tools Rate Thread

Macro to delete current row AND delete objects also located in thatrow.

 
 
Tonso
Guest
Posts: n/a
 
      26th Jan 2009
Is there a way to, when a macro deletes the current row, to also have
it find and delete any drawn objects [circles, rectangles, etc]. when
my macro deletes a row, a remnant of the drawn object, which appears
as a line, remains.
I am using XL 2002.

Thanks,

Tonso
 
Reply With Quote
 
 
 
 
Gord Dibben
Guest
Posts: n/a
 
      26th Jan 2009
The drawing object is not part of the row so won't be deleted with the
row(s)

Set its properties to "move but not size with cells" and it won't shrink up
to a line when you delete rows.


Gord Dibben MS Excel MVP

On Mon, 26 Jan 2009 13:41:49 -0800 (PST), Tonso <(E-Mail Removed)>
wrote:

>Is there a way to, when a macro deletes the current row, to also have
>it find and delete any drawn objects [circles, rectangles, etc]. when
>my macro deletes a row, a remnant of the drawn object, which appears
>as a line, remains.
>I am using XL 2002.
>
>Thanks,
>
>Tonso


 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      27th Jan 2009
Maybe...

First, Ron de Bruin has a lot of info on this page:
http://www.rondebruin.nl/controlsobjectsworksheet.htm

There are a lot of shapes you do not want to delete (data|validation dropdowns,
arrows from autofilters, comments and any more you can think of...)

Option Explicit
Sub testme()

Dim shp As Shape
Dim testStr As String
Dim RowToDelete As Long
Dim TopLeftCellRow As Long
Dim OkToDelete As Boolean

RowToDelete = 3

For Each shp In ActiveSheet.Shapes
TopLeftCellRow = 0
On Error Resume Next
TopLeftCellRow = shp.TopLeftCell.Row
On Error GoTo 0
If TopLeftCellRow = 0 Then
'not a shape to delete, so skip it
Else
If TopLeftCellRow = RowToDelete Then
OkToDelete = True
If shp.Type = msoComment Then
OkToDelete = False
ElseIf shp.Type = msoFormControl Then
If shp.FormControlType = xlDropDown Then
'it might be a data|validation dropdown
testStr = ""
On Error Resume Next
testStr = shp.TopLeftCell.Address
On Error GoTo 0
If testStr = "" Then
OkToDelete = False
End If
End If
End If
If OkToDelete Then
shp.Delete
End If
End If
End If
Next shp
End Sub


Tonso wrote:
>
> Is there a way to, when a macro deletes the current row, to also have
> it find and delete any drawn objects [circles, rectangles, etc]. when
> my macro deletes a row, a remnant of the drawn object, which appears
> as a line, remains.
> I am using XL 2002.
>
> Thanks,
>
> Tonso


--

Dave Peterson
 
Reply With Quote
 
Tonso
Guest
Posts: n/a
 
      27th Jan 2009
On Jan 26, 6:04*pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> Maybe...
>
> First, Ron de Bruin has a lot of info on this page:http://www.rondebruin.nl/controlsobjectsworksheet.htm
>
> There are a lot of shapes you do not want to delete (data|validation dropdowns,
> arrows from autofilters, comments and any more you can think of...)
>
> Option Explicit
> Sub testme()
>
> * * Dim shp As Shape
> * * Dim testStr As String
> * * Dim RowToDelete As Long
> * * Dim TopLeftCellRow As Long
> * * Dim OkToDelete As Boolean
>
> * * RowToDelete = 3
>
> * * For Each shp In ActiveSheet.Shapes
> * * * * TopLeftCellRow = 0
> * * * * On Error Resume Next
> * * * * TopLeftCellRow = shp.TopLeftCell.Row
> * * * * On Error GoTo 0
> * * * * If TopLeftCellRow = 0 Then
> * * * * * * 'not a shape to delete, so skip it
> * * * * Else
> * * * * * * If TopLeftCellRow = RowToDelete Then
> * * * * * * * * OkToDelete = True
> * * * * * * * * If shp.Type = msoComment Then
> * * * * * * * * * * OkToDelete = False
> * * * * * * * * ElseIf shp.Type = msoFormControl Then
> * * * * * * * * * * If shp.FormControlType = xlDropDown Then
> * * * * * * * * * * * * 'it might be a data|validation dropdown
> * * * * * * * * * * * * testStr = ""
> * * * * * * * * * * * * On Error Resume Next
> * * * * * * * * * * * * testStr = shp.TopLeftCell.Address
> * * * * * * * * * * * * On Error GoTo 0
> * * * * * * * * * * * * If testStr = "" Then
> * * * * * * * * * * * * * * OkToDelete = False
> * * * * * * * * * * * * End If
> * * * * * * * * * * End If
> * * * * * * * * End If
> * * * * * * * * If OkToDelete Then
> * * * * * * * * * * shp.Delete
> * * * * * * * * End If
> * * * * * * End If
> * * * * End If
> * * Next shp
> End Sub
>
> Tonso wrote:
>
> > Is there a way to, when a macro deletes the current row, to also have
> > it find and delete any drawn objects [circles, rectangles, etc]. when
> > my macro deletes a row, a remnant of the drawn object, which appears
> > as a line, remains.
> > I am using XL 2002.

>
> > Thanks,

>
> > Tonso

>
> --
>
> Dave Peterson


Thanks! This macro should do what i need. And thanks for introducing
me to Ron's info.

Tonso
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How send a report and also pdf files located in c: drive? ldiaz Microsoft Access 5 28th Sep 2008 07:19 AM
if ... then ... also .... also ..... also =?Utf-8?B?U2lsdmlv?= Microsoft Access Forms 2 31st Oct 2006 10:58 PM
Need to enable the objects to also be inserted into current slide in normal view, not just a selected slide Tyron Microsoft Powerpoint 1 23rd Jun 2005 02:25 AM
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below Annette Microsoft Excel Programming 2 21st Sep 2004 02:40 PM
cannot shift objects off sheet, but also cannot find objects danielo Microsoft Excel Misc 6 5th Aug 2004 09:17 PM


Features
 

Advertising
 

Newsgroups
 


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