Why doesn't resizing a rectangle work in Excel?

Hi Experts!

This is probably a very easy fix but it is driving me nuts. I have some rectangles on the screen. I want to resize them. I recorded a macro that drags the top edge up and get this code:

    ActiveSheet.Shapes("MyBar").Select
    Selection.ShapeRange.ScaleHeight (200), msoFalse, msoScaleFromBottomRight

The problem is when I run the code it resizes downward. Is there a way to force VBA to resize my rectangle up (i.e., anchor the bottom so it doesn't move)?

Thanks!
Ed MatsuokaPartner/Senior IT SpecialistAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

Could you send a dummy?

EDIT Are you sure your Shape is upwards

Regards
0
Ejgil HedegaardCommented:
You increase the height 200 times.
Probably the rectangle hit the top of the sheet, and then it scales down to make the correct size.
Try setting the scale factor to something small, like 1.2, and see what happens.
0
Martin LissOlder than dirtCommented:
Try working with the Height rather than the ScaleHeight,

This will increase the height by a maximum of 200. In other words if there's room enough between the top of the shape and the top of the sheet, the shape will increase in height by 200, otherwise the height will be increased only by as much as it can be without moving the bottom.

Sub SetHeight()

Const HITE = 200

Application.ScreenUpdating = False
ActiveSheet.Shapes("MyBar").Select
If Selection.Top - HITE < 0 Then
    Selection.HEIGHT = Selection.HEIGHT + Selection.Top
    Selection.Top = 0
Else
    Selection.HEIGHT = Selection.HEIGHT + HITE
    Selection.Top = Selection.Top - HITE
End If

Application.ScreenUpdating = True
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Ed MatsuokaPartner/Senior IT SpecialistAuthor Commented:
Thanks for the quick replies. The "200" is my fault, I just chose a number out of my hat (I don't use the other word!) since there was an array there which would just confuse the issue.

Martin I will try your code this morning.
0
Ed MatsuokaPartner/Senior IT SpecialistAuthor Commented:
Hi Martin,

With a little tweaking your code did the trick. Thanks and have a great day!
0
Martin LissOlder than dirtCommented:
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2015
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.