Move (grouped) shape 5 columns to the left

RemcoVBA

New Member
Joined
Sep 21, 2021
Messages
8
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

I've got a grouped shape that will move based on the cell value entered in cell A1.
Now I want this grouped shaped to always move 5 columns to the left.

So when I enter value M8 in cell A1 VBA should automatically move the grouped shape to H8 (at least that is the upper left corner of the grouped shape.)
I've tried using offset but I guess i'm using a wrong syntax. Can anyone help me out?

So far this is my code:

Public Sub Move_shape()

Dim oShape As Shape

Set oShape = ActiveSheet.Shapes("Group 7")

Dim oCell As Range

Set oCell = Range(Range("A1").Value)


'the value of Range("A1) will be a text saying which cell the shape will go to.


oShape.Top = oCell.Top
oShape.Left = oCell.Left


End Sub



Thanks Remco
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
How about ...

VBA Code:
Public Sub RemcoVBA()

    With ActiveSheet
        Dim oShape As Shape
        Set oShape = .Shapes("Group 7")
        Dim oCell As Range
        On Error Resume Next
        Set oCell = .Range(.Range("A1").Value).Offset(0, -5)
        On Error GoTo 0
    End With

    If Not oCell Is Nothing Then
        oShape.Top = oCell.Top
        oShape.Left = oCell.Left
    End If
End Sub
 
Upvote 0
Solution
You are welcome and thanks for the feedback (y)
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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