Vba Decrease width from left

mahmed1

Well-known Member
Joined
Mar 28, 2009
Messages
2,302
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi All

I have a shape that when i run the macro, the shape gets smaller so its like its sliding open

for i = 500 to 1 step -5
DoEvents
worksheets("mysheet").shapes("moveleft").width = i
nexi i

What i want to do is have that same effect on my shape named moveright but get the shape to move right when decreasing so its like the shape is opening like a sliding door going right

please help me get this effect because by flipping the variable wont work

ie i = 1 to 500
 
Hi Peter - I have manged to get the position of the 4 shapes so that it always defaults to the original position but im still getting an error with the grouping part

Thank You
Code:
Sub test()


'I have many shapes but these are the 4 shapes i want to be able to move about when displayed


With ActiveSheet.Shapes("Shape1")
    .Left = 87
    .Top = 179.25
End With


With ActiveSheet.Shapes("Shape2")
    .Left = 256.5
    .Top = 212.2501
End With


With ActiveSheet.Shapes("Shape3")
    .Left = 258.7499
    .Top = 115.5
End With


With ActiveSheet.Shapes("Shape4")
    .Left = 97.5
    .Top = 305.25
End With


With ActiveSheet.Shapes.Range(Array("Shape1", "Shape2", "Shape3", "Shape4"))
  .Group
  .Name = "DisplayGroup"
End With


For i = 0.99 To 0 Step -0.07
    Application.ScreenUpdating = False
    ActiveSheet.Shapes("DisplayGroup").Fill.Transparency = i
    Application.ScreenUpdating = True
    DoEvents
Next i
'ActiveSheet.Shapes("DisplayGroup").Fill.Transparency = 0   '(or 1)


ActiveSheet.Shapes("DisplayGroup").Ungroup


End Sub
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi peter - is there any way i could send you the spreadsheet if possible?
 
Upvote 0
Thanks to your help Peter - i am nearly there. You have been awesome

Can i please send you the worksheet so you can see where im going wrong as 1 shape is still not setting the transparency to 1 when i am hiding it and the shape outline is also not being changed when the transparency is set to 1 on most shapes

Many Thanks
 
Upvote 0
Hi Peter

I managed to get the issue sorted by sending that image affected to the back

1 slight amendment and was hoping you can help me please

with the current code - this works beautifully

when transparency is going from 0 to 1

is there a way i can keep rotating the image named centerimage clockwise quickly and at the end go back to its original position?

i know this code
activesheet.shapes("centerimage").rotation = i will rotate based on the i variable but the doEvents spins this very slowly.

I want it to spin quickly whilst the transparency bit of the code is going to 1..can you please help me achieve this

thank you again

really appreciate this
 
Upvote 0
I want it to spin quickly whilst the transparency bit of the code is going to 1..can you please help me achieve this
I don't think so. You need the DoEvents to show the (slower) movement of some shapes and of course that has to also have an impact on the (faster) movement of the other shape. I suppose it isn't surprising that this is proving difficult as you are trying to get a spreadsheet application to perform like a graphics one. :)

Still, somebody might come up with a solution.
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top