Shape Moving

mudflap

New Member
Joined
Sep 26, 2009
Messages
34
I have a macro assigned to a shape and I would like it to follow the page as I scroll down is this possible?

Thanks
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,266
Office Version
  1. 2013
Platform
  1. Windows
Try this:

This script will follow the active cell.
So when you click on a cell the shape will be next to the active cell.

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

I named my shape MY_Shape.
Modify name to your needs.


Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Modified  11/16/2018  7:29:50 AM  EST
Shapes("My_Shape").Top = ActiveCell.Top
Shapes("My_Shape").Left = ActiveCell.Offset(, 1).Left
End Sub
 

mudflap

New Member
Joined
Sep 26, 2009
Messages
34

ADVERTISEMENT

Is it possible to put this code in my Persional.XLSB so it will automatically run on all of my workbooks? I have a lot of worksheets in each workbook and i don't want to have to put this code in each sheet.

Thanks
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,266
Office Version
  1. 2013
Platform
  1. Windows
No. As far as I know a sheet selection change event cannot be installed in the Personal Workbook.

Tell me what do you do with this shape. Do you have a script assigned to this shape.

I may have another way we could do this. Is your whole ideal to have this button close by so you can click it to run a script?

If so post the script here.
 
Last edited:

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,266
Office Version
  1. 2013
Platform
  1. Windows

ADVERTISEMENT

Now that I look at your original post again I see you have a script assigned to the shape.

Why not run the script with a shortcut key. Then this script could be installed in the Personal Workbook and could be run in any sheet or workbook.
 

mudflap

New Member
Joined
Sep 26, 2009
Messages
34
I cant seem to get that to work.

I think some thing needs to be charged in the code in order for it to work. I will keep trying otherwise ill just start putting the code in each sheet.

Thank you for the help.
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,266
Office Version
  1. 2013
Platform
  1. Windows
Not sure what your saying. I asked what is your script in the shape doing. I said show me your script. And you did not answer my question.
I cant seem to get that to work.

I think some thing needs to be charged in the code in order for it to work. I will keep trying otherwise ill just start putting the code in each sheet.

Thank you for the help.
 

mudflap

New Member
Joined
Sep 26, 2009
Messages
34
Sorry I was replying to the message after that one. Im not sure how to post my code.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,505
Messages
5,602,062
Members
414,498
Latest member
jordanmiller7890

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
Top