ActiveX Textbox on Sheet - Scroll Using VBA

Jeffrey Mahoney

Well-known Member
Joined
May 31, 2015
Messages
3,244
Office Version
  1. 365
Platform
  1. Windows
I have several ActiveX Textboxes that are linked to several cells with formulas to change the text based on another cell. They are locked and my sheet is protected. This allows the user to click the text box and scroll if the text lines are longer than the control.

Issues:
1. Users don't know how to click away from the control to scroll down through the rest of the Sheet form
2. Sometimes the textboxes resize themselves (I've added code to resize them to their default upon focus)

I would rather use a different control to scroll through the text.

How do I control the scroll bar for an ActiveX Textbox using VBA?
 
Setting the CurLine Property will move the scroll bar.

VBA Code:
Sub Demo()
    With Sheet1.TextBox1
        ' Set focus to the TextBox
        .Activate
        ' Jump to the first line
        .CurLine = 0
        ' Wait 3 secs
        Application.Wait Now + TimeSerial(0, 0, 3)
        ' Jump to the last line
        .CurLine = .LineCount - 1
    End With
End Sub
 
Upvote 0
No as far as I know ... What is the issue with activating the textbox?
Well, this may seem unimportant.

When I give focus to the textboxes, they shift in size and location. I created a macro to put them back when they get focus. That kind of solves that.

But, users (with less skill on how to navigate a worksheet) struggle to click away from the control so they can scroll further down the form.

I thought it would be great to have a scrollbar that controls the textbox without giving focus to it.
 
Upvote 0
You could store the current focus before scrolling, then set the focus on the textbox, scroll and get back to the previously stored focus. Do you have a screenshot, video or file as sample of what you want to do?
 
Upvote 0
Yes. As pointed out by Edgar_, cache the selected range before activating the textbox and get back to the cached range afterwards. Disabling ScreenUpdating would be very useful here to prevent worksheet jumping.

An yes, a screenshot or video sample would be useful.
 
Upvote 0

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