Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Paste Graphic in Cell's Center

I have a graphic (bull's eye) frequently used to signify completion of a
task. It is copy/pasted into a cell - the problem is, I have to move it
around manually to ge it in the center of the cell. A real problem with
different size cells. Is there a way to make the graphic fit exactly in the
center of the cell on paste?

Thanks, Phil
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Paste Graphic in Cell's Center

Hi Phil,

The following will position the latest shape on the activesheet in the
center of the active cell. Hopefully you can modify the code to suit you
particular code.

Sub PasteCenter()

Dim shpTemp As Shape

If ActiveSheet.Shapes.Count 0 Then
' use latest shape
Set shpTemp = ActiveSheet.Shapes(ActiveSheet.Shapes.Count)

shpTemp.Left = ActiveCell.Left + _
((ActiveCell.Width - shpTemp.Width) / 2)
shpTemp.Top = ActiveCell.Top + _
((ActiveCell.Height - shpTemp.Height) / 2)

Set shpTemp = Nothing
End If

End Sub

Cheers
Andy

Phil Hageman wrote:
I have a graphic (bull's eye) frequently used to signify completion of a
task. It is copy/pasted into a cell - the problem is, I have to move it
around manually to ge it in the center of the cell. A real problem with
different size cells. Is there a way to make the graphic fit exactly in the
center of the cell on paste?

Thanks, Phil


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Paste Graphic in Cell's Center

Thanks, Andy. I named this code Sub CenterPastedObjects, and put it in
Module 1 of my Personal.xls. However, I cant get it to work - at all. Where
am I going wrong?

Thanks, Phil

"Andy Pope" wrote:

Hi Phil,

The following will position the latest shape on the activesheet in the
center of the active cell. Hopefully you can modify the code to suit you
particular code.

Sub PasteCenter()

Dim shpTemp As Shape

If ActiveSheet.Shapes.Count 0 Then
' use latest shape
Set shpTemp = ActiveSheet.Shapes(ActiveSheet.Shapes.Count)

shpTemp.Left = ActiveCell.Left + _
((ActiveCell.Width - shpTemp.Width) / 2)
shpTemp.Top = ActiveCell.Top + _
((ActiveCell.Height - shpTemp.Height) / 2)

Set shpTemp = Nothing
End If

End Sub

Cheers
Andy

Phil Hageman wrote:
I have a graphic (bull's eye) frequently used to signify completion of a
task. It is copy/pasted into a cell - the problem is, I have to move it
around manually to ge it in the center of the cell. A real problem with
different size cells. Is there a way to make the graphic fit exactly in the
center of the cell on paste?

Thanks, Phil


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Paste Graphic in Cell's Center

Hi Phil,

If no error is occurring then the IF THEN test must be failing.
The code doesn't actually paste anything it only works for the last
shape placed on the activesheet.

If there is an error can you let me know what it is.

Cheers
Andy


Phil Hageman wrote:
Thanks, Andy. I named this code Sub CenterPastedObjects, and put it in
Module 1 of my Personal.xls. However, I cant get it to work - at all. Where
am I going wrong?

Thanks, Phil

"Andy Pope" wrote:


Hi Phil,

The following will position the latest shape on the activesheet in the
center of the active cell. Hopefully you can modify the code to suit you
particular code.

Sub PasteCenter()

Dim shpTemp As Shape

If ActiveSheet.Shapes.Count 0 Then
' use latest shape
Set shpTemp = ActiveSheet.Shapes(ActiveSheet.Shapes.Count)

shpTemp.Left = ActiveCell.Left + _
((ActiveCell.Width - shpTemp.Width) / 2)
shpTemp.Top = ActiveCell.Top + _
((ActiveCell.Height - shpTemp.Height) / 2)

Set shpTemp = Nothing
End If

End Sub

Cheers
Andy

Phil Hageman wrote:

I have a graphic (bull's eye) frequently used to signify completion of a
task. It is copy/pasted into a cell - the problem is, I have to move it
around manually to ge it in the center of the cell. A real problem with
different size cells. Is there a way to make the graphic fit exactly in the
center of the cell on paste?

Thanks, Phil


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
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
Center Comments on Center of Screen Raymond W. Excel Discussion (Misc queries) 5 September 15th 09 04:58 PM
Merge and Center and Center Accross Selection Bojingles03 New Users to Excel 3 March 17th 09 07:05 PM
Any way to center a graphic in a particular cell? metalsped Excel Discussion (Misc queries) 8 May 6th 06 06:53 AM
Add buttons for Center Across and Paste Formula Ronmi Excel Discussion (Misc queries) 1 May 16th 05 01:15 AM
Center Across Selection Vertically Help. I am trying to center te. msond Excel Discussion (Misc queries) 1 March 29th 05 12:37 PM


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

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"