Moving shape based on Cell Value

gmedalla999

New Member
Joined
Apr 23, 2016
Messages
8
Hello all,

I am very new to the forum and very new with the use of Macro as well. I wish to be able to move an object to a certain cell (using .top and .left). It is important the location be referenced to the cell versus increment or numerical value. Below is the sample of my code but I could not make it work. Cell I1 is the input cell where I will type which cell the object will go to, i.e. Cell J10? I would greatly appreciate any help I could get. thanks

Sub ShiftShape()

Dim oShape As Shape

Set oShape = ActiveSheet.Shapes("Flowchart: Decision 3")


Dim oCell As Range

Set oCell = ActiveSheet.Range("I1").Value

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


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


End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi gmedalla999,

Welcome to the forum :)

Try;

Code:
Sub ShiftShape()
Rng = ActiveSheet.Range("I1").Value
ActiveSheet.Shapes("Flowchart: Decision 3").Top = Range(Rng).Top
ActiveSheet.Shapes("Flowchart: Decision 3").Left = Range(Rng).Left
End Sub

Hope this helps,
Cheers,
Alan.
 
Upvote 0
Hi, welcome to the board:

You could try changing the "SetOcell..." line to this:
Code:
Set oCell = Range(Range("I1").Value)
 
Upvote 0
Hi gmedalla999,

Welcome to the forum :)

Try;

Code:
Sub ShiftShape()
Rng = ActiveSheet.Range("I1").Value
ActiveSheet.Shapes("Flowchart: Decision 3").Top = Range(Rng).Top
ActiveSheet.Shapes("Flowchart: Decision 3").Left = Range(Rng).Left
End Sub

Hope this helps,
Cheers,
Alan.

Thank you Allan this works quite well too. i will use it as well
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,304
Members
452,633
Latest member
DougMo

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