Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Center Comments on Center of Screen | Excel Discussion (Misc queries) | |||
Merge and Center and Center Accross Selection | New Users to Excel | |||
Any way to center a graphic in a particular cell? | Excel Discussion (Misc queries) | |||
Add buttons for Center Across and Paste Formula | Excel Discussion (Misc queries) | |||
Center Across Selection Vertically Help. I am trying to center te. | Excel Discussion (Misc queries) |