Text box that moves when scrolling

glad_ir

Board Regular
Joined
Nov 22, 2020
Messages
143
Office Version
  1. 2010
Platform
  1. Windows
Hello everybody,

I’m hoping for some help please. I’d like to achieve a text box or text in a row that centres on the screen as the user scrolls horizontally but moves with the row when they scroll vertically.
Is this even achievable? Any thoughts much appreciated.

thank you, Iain
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I have no answer for what you want as far as scrolling.
But this script will move the TextBox as you select different cells.
Try this and see if this will work.

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
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Modified  11/23/2020  10:22:06 PM  EST
    TextBox1.Top = ActiveCell.Offset(2).Top
  If Target.Column > 3 Then TextBox1.Left = ActiveCell.Offset(, -2).Left
End Sub
 
Last edited:
Upvote 0
You may want to play around with the code a little to get the textbox positioned exactly where you like. You should see the ideal of how it works.
 
Upvote 0
You may want to play around with the code a little to get the textbox positioned exactly where you like. You should see the ideal of how it works.
Hi, thank you for replying. I am getting a debug error when I try to run this. Any thoughts? Could well be me doing something wrong. I have a TextBox1 in the sheet and have pasted the macro in the worksheet as suggested. Thank you
1606193914903.png
 
Upvote 0
Is it causing a error all the time or just when you click on certain cells.
It works for me.
Are you using a Activex Textbox?
 
Upvote 0
Hi.....it's causing an error when I click on a cell. I've inserted a textbox - not sure if it's an Active Textbox. Please could you advise how I insert one of these. Sorry - real newby here!
 
Upvote 0
Hi.....it's causing an error when I click on a cell. I've inserted a textbox - not sure if it's an Active Textbox. Please could you advise how I insert one of these. Sorry - real newby here!
Well put the Textbox on the sheet before putting the code in the sheet
Do not understand:
how I insert one of these
 
Upvote 0
Is it causing a error all the time or just when you click on certain cells.
It works for me.
Are you using a Activex Textbox?
Hi - I've managed to insert a ComboBox using the Developer tab and modified the code from TextBox to ComboBox. It's not erroring but isn't moving the box.

1606195984012.png
 
Upvote 0
Are you sure your not still in Design Mode?
Is Your Workbook Macro Enable?
Have you ever used Vba Before?
 
Upvote 0
Are you sure your not still in Design Mode?
Is Your Workbook Macro Enable?
Have you ever used Vba Before?
Hi - thank you for your patience.....it is now working now I've fixed my incompetence (had left myself in design mode)!! I have done some very basic VBA coding but nothing of this complexity. I'm discovering ActiveX controls for the first time.....lots to learn. Thank you very much for your help. I really appreciate it :)
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,688
Members
448,978
Latest member
rrauni

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