ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Position drawing object relative to cell (https://www.excelbanter.com/excel-discussion-misc-queries/204347-position-drawing-object-relative-cell.html)

Horatio J. Bilge, Jr.

Position drawing object relative to cell
 
I am trying to work out how to position an oval over a cell. On frmOval, if
the user selects a certain radio button, I want an oval to appear over a
specified cell.

I drew an oval of the correct size, and I would like to copy and paste it to
the correct spot. This is what I got from the Macro recorder, by copying,
pasting, and moving it into position. It seems clunky, and I'm wondering if
there is an easier way to specify the position relative to the cell. There
are 11 possible cell positions, based on 11 radio buttons.

If Me.optOval01.Value = True Then
ActiveSheet.Shapes("Oval 11").Select
Selection.Copy
ActiveSheet.Paste
Selection.ShapeRange.IncrementLeft -12#
Selection.ShapeRange.IncrementTop 18#
End If


Jim Thomlinson

Position drawing object relative to cell
 
Here is some code to move an oval... You can use the height and width to
further move the oval.

Sub test()
Call MoveOval(Shapes("Oval 11"), Range("C10"))
End Sub

Sub MoveOval(ByRef shp As Shape, cell As Range)
'pass in a shape and a cell
shp.Top = cell.Top
shp.Left = cell.Left
End Sub
--
HTH...

Jim Thomlinson


"Horatio J. Bilge, Jr." wrote:

I am trying to work out how to position an oval over a cell. On frmOval, if
the user selects a certain radio button, I want an oval to appear over a
specified cell.

I drew an oval of the correct size, and I would like to copy and paste it to
the correct spot. This is what I got from the Macro recorder, by copying,
pasting, and moving it into position. It seems clunky, and I'm wondering if
there is an easier way to specify the position relative to the cell. There
are 11 possible cell positions, based on 11 radio buttons.

If Me.optOval01.Value = True Then
ActiveSheet.Shapes("Oval 11").Select
Selection.Copy
ActiveSheet.Paste
Selection.ShapeRange.IncrementLeft -12#
Selection.ShapeRange.IncrementTop 18#
End If


Horatio J. Bilge, Jr.

Position drawing object relative to cell
 
That helps. I was able to adapt it to fit my needs.
Thanks,
~ Horatio

"Jim Thomlinson" wrote:

Here is some code to move an oval... You can use the height and width to
further move the oval.

Sub test()
Call MoveOval(Shapes("Oval 11"), Range("C10"))
End Sub

Sub MoveOval(ByRef shp As Shape, cell As Range)
'pass in a shape and a cell
shp.Top = cell.Top
shp.Left = cell.Left
End Sub
--
HTH...

Jim Thomlinson


"Horatio J. Bilge, Jr." wrote:

I am trying to work out how to position an oval over a cell. On frmOval, if
the user selects a certain radio button, I want an oval to appear over a
specified cell.

I drew an oval of the correct size, and I would like to copy and paste it to
the correct spot. This is what I got from the Macro recorder, by copying,
pasting, and moving it into position. It seems clunky, and I'm wondering if
there is an easier way to specify the position relative to the cell. There
are 11 possible cell positions, based on 11 radio buttons.

If Me.optOval01.Value = True Then
ActiveSheet.Shapes("Oval 11").Select
Selection.Copy
ActiveSheet.Paste
Selection.ShapeRange.IncrementLeft -12#
Selection.ShapeRange.IncrementTop 18#
End If



All times are GMT +1. The time now is 09:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com