Move Shapes or Objects

GomaPile

Active Member
Joined
Jul 24, 2006
Messages
334
Office Version
  1. 365
Platform
  1. Windows
Hi All,

Is there anyone who knows how to move shapes or objects in excel 2016 around a spreadsheet.

The vba code below works fine, the shape moves back & forth Left to Right with Red Off | Green On. But I can't figure out how to move the shape Up & Down and keeping the Red Off | Green On as the same.

Cell A1 if the value = 1 or nothing (cool way to switch the formula Off/On).

Code:
Sub ADOSwitch()
    
With Application
        .ScreenUpdating = False
        .EnableEvents = False
End With
    If Range("A1").Value = "1" Then
        
        ActiveSheet.Shapes("btnADO").IncrementLeft -47
        ActiveSheet.Shapes.Range(Array("btnADO")).Select
        Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "OFF"
            With Selection.ShapeRange.Fill
                .Visible = msoTrue
                .ForeColor.RGB = RGB(200, 0, 0)
                .Transparency = 0
                .Solid
                Range("A1").Select
        End With
    
    Range("A1").Value = "0"
    'MsgBox "off"
    Else: Range("A1").Value = "1"
    
        ActiveSheet.Shapes("btnADO").IncrementLeft 47
        ActiveSheet.Shapes.Range(Array("btnADO")).Select
        Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "ON"
            With Selection.ShapeRange.Fill
                .Visible = msoTrue
                .ForeColor.RGB = RGB(0, 176, 80)
                .Transparency = 0
                .Solid
                Range("A1").Select
            End With
    'MsgBox "on"
    End If
With Application
        .ScreenUpdating = True
        .EnableEvents = True
End With

End Sub

Regards :)
Goma (NASA)
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
ActiveSheet.Shapes("btnADO").IncrementTop 50

Thanks rpaulson I appreciate your help, so simple.

I had slightly changed the values for it to move up and down;

Code:
ActiveSheet.Shapes("btnADO").IncrementTop -45 '(= "OFF")
and
ActiveSheet.Shapes("btnADO").IncrementTop 45 '(= "ON")

Cheers :)
Goma (NASA)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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