Consulting

Results 1 to 3 of 3

Thread: Solved: Force shape to be inserted in middle of cell

  1. #1

    Solved: Force shape to be inserted in middle of cell

    Hi Everyone! I have a macro which based upon a value should return a shape. I have the shapes on a separate (hidden) worksheet. As I have never worked with shapes, I tried to record a macro which copies the shape to the sheet and cell I need, and I moved the shape in the middle of the cell. The problem is that each time I run the macro, the shape is pasted on a different location (close to the location I need). How can I force the shape to be in the middle of the cell "H5"? Thank you in advance for your help!

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    With ActiveSheet.Shapes("myShape")

    .Top = Range("H5").Top + Range("H5").Height / 2 - .Height / 2
    .Left = Range("H5").Left + Range("H5").Width / 2 - .Width / 2
    End With
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Thank you Xld! It is working!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •