PC Review


Reply
Thread Tools Rate Thread

Deleting a shape and the cell contents the shape is in.

 
 
John DeFiore
Guest
Posts: n/a
 
      8th Oct 2003
Someone here was kind enough to show me how to delete a
shape that's in the active cell, along with the cell
contents. This is for a macro that's attached to a
button. The user clicks a cell, then that cell and the
shape (basically a dot) in the cell is deleted. No
problem, unless instead of clicking the cell, the user
clicks in the dot in the cell and selects IT instead of
activating the cell. Unhappiness. How would I first
delete any selected shape and the contents of the cell in
which it is (entirely) located? I could then be sure I
had both cases covered and the macro would always work.

Thanks,

John
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      9th Oct 2003
You could check to see what's selected with:
typename(selection)

Option Explicit
Sub testme()

MsgBox TypeName(Selection)
Select Case TypeName(Selection)
Case Is = "Range"
'cell is selected, do that
Case Else
Selection.TopLeftCell.ClearContents
Selection.Delete
End Select

End Sub

I put some circles/ellipses in some cells and ran the macro. Typename returned
Oval.

You could check for each type that you're using or just quit if it's not a range
(force them to be more careful).





John DeFiore wrote:
>
> Someone here was kind enough to show me how to delete a
> shape that's in the active cell, along with the cell
> contents. This is for a macro that's attached to a
> button. The user clicks a cell, then that cell and the
> shape (basically a dot) in the cell is deleted. No
> problem, unless instead of clicking the cell, the user
> clicks in the dot in the cell and selects IT instead of
> activating the cell. Unhappiness. How would I first
> delete any selected shape and the contents of the cell in
> which it is (entirely) located? I could then be sure I
> had both cases covered and the macro would always work.
>
> Thanks,
>
> John


--

Dave Peterson
(E-Mail Removed)
 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      9th Oct 2003
if typename(selection) <> "Range" then
selection.TopLeftCell.Select
End if
' your current code

--
Regards,
Tom Ogilvy


John DeFiore <(E-Mail Removed)> wrote in message
news:0eae01c38ded$d1b34c20$(E-Mail Removed)...
> Someone here was kind enough to show me how to delete a
> shape that's in the active cell, along with the cell
> contents. This is for a macro that's attached to a
> button. The user clicks a cell, then that cell and the
> shape (basically a dot) in the cell is deleted. No
> problem, unless instead of clicking the cell, the user
> clicks in the dot in the cell and selects IT instead of
> activating the cell. Unhappiness. How would I first
> delete any selected shape and the contents of the cell in
> which it is (entirely) located? I could then be sure I
> had both cases covered and the macro would always work.
>
> Thanks,
>
> John



 
Reply With Quote
 
John DeFiore
Guest
Posts: n/a
 
      9th Oct 2003
Thanks for the reply, Dave.

Regards,

John
>-----Original Message-----
>You could check to see what's selected with:
>typename(selection)
>
>Option Explicit
>Sub testme()
>
> MsgBox TypeName(Selection)
> Select Case TypeName(Selection)
> Case Is = "Range"
> 'cell is selected, do that
> Case Else
> Selection.TopLeftCell.ClearContents
> Selection.Delete
> End Select
>
>End Sub
>
>I put some circles/ellipses in some cells and ran the

macro. Typename returned
>Oval.
>
>You could check for each type that you're using or just

quit if it's not a range
>(force them to be more careful).
>
>
>
>
>
>John DeFiore wrote:
>>
>> Someone here was kind enough to show me how to delete a
>> shape that's in the active cell, along with the cell
>> contents. This is for a macro that's attached to a
>> button. The user clicks a cell, then that cell and the
>> shape (basically a dot) in the cell is deleted. No
>> problem, unless instead of clicking the cell, the user
>> clicks in the dot in the cell and selects IT instead of
>> activating the cell. Unhappiness. How would I first
>> delete any selected shape and the contents of the cell

in
>> which it is (entirely) located? I could then be sure I
>> had both cases covered and the macro would always work.
>>
>> Thanks,
>>
>> John

>
>--
>
>Dave Peterson
>(E-Mail Removed)
>.
>

 
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
Create shape, name shape, add text to shape Rick S. Microsoft Excel Programming 2 27th Feb 2010 07:11 PM
Show shape on cell select, Hide shape when cell is deselected Max Microsoft Excel Programming 5 27th Jan 2010 11:04 AM
Display cell contents in a text box (shape) and linking andreashermle Microsoft Excel Programming 2 16th Dec 2009 02:55 PM
Make a cell display the contents of a shape JasperBluto Microsoft Excel Worksheet Functions 0 29th Aug 2008 06:17 AM
PowerPoint events for adding a shape, deleting a shape and slide Mark Kestenbaum Microsoft Powerpoint 1 3rd Jan 2008 12:04 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:59 PM.