Excel VBA: Connect Scrollbar and Textbox in Userform - excel

I have a userform with a scrollbar and textbox.
How do you code it so that the scrollbar connects to the textbox?
For example, I want the textbox to increase/decrease by a value each time you click the up/down-arrow on the scrollbar.

You don't say what version of Excel you are using so see if this works for you.
To get a spinner or scrollbar to work you can connect it to a cell by right-clicking on the scroll bar control and selecting Properties | Format Control | Control and then select the cell by using the Cell Link property at the bottom to select and link the cell you want to increment/decrement by using the scrollbar
If you haven't already linked the textbox to that cell, you can do so by
First - select the text box
Second - put your cursor in the formula bar
Third - type in = symbol and then click on the above cell you want
to link to,
Finally - press the Enter key

Related

Excel activex textbox - unable to select for typing

Office 365/Excel, I did the following:
Open New blank workbook.worksheet
Insert activex textbox 3)properties - link to a cell (G1).
But when out of design mode and selecting the textbox to type, the cursor is not showing - that is, no invitation to type anything. If I type something in G1, that value appears in the textbox. If I type something in the textbox, the characters are invisible in the textbox but appear dynamically in G1, and then appear in the textbox when I click outside the textbox.
Also, if I format textbox to change the order to something else (say "bring to front"), I can type in the textbox OK, but when I click outside, the behaviour returns.
I read somewhere a textbox is bi-directional and this appears to be so, except for being unable to see the characters typed in the textbox.
Wondering if you're using external monitors?
There seems to be a bug in Excel and I had the exact same issue. As soon as I unplugged the second monitor or (actually just moving the Excel document to the main screen, the ActiveX textbox was working as intended).
Hope that helps.

Excel VBA function that can recalculate on scroll

I am trying to find a way to detect scrolling in Excel since its not possible out of the box and I used the following macro to check the row number of the top left visible cell in the active window:
Function Scroll() As Double
Scroll = ActiveWindow.ScrollRow
End Function
So in excel if I paste the formula =Scroll() into any cell, it actually gives me the top visible cell row. When I scroll it doesn't update but if i click on the cell, then click on formula bar and press Enter it then updates again. Is there a way around this or that's just a limitation in Excel.

Excel Userform Textbox Drag or Drag away

If I enable the Drag and Drop behaviour for a textbox on an Excel userform, I can trigger an event simply by hovering the mouse over the texbox. If I then move the mouse away without dropping the item onto the texbox, I want the event to be cancelled. Is there any way I can do this?
Simple example: I hover the mouse over the textbox, a checkbox is ticked. I move the mouse away without dropping and the checkbox is un-ticked.
By validating the DragState of the mouse I was able to do this:
If DragState = fmDragStateLeave Then

How to select range cell with VBA and align to top instead to the middle of the window?

I created a hiperlink, but this is not working correctly. When the vba is executed, always the selected cell is in the middle of the window, i want to align the selected cell to the top left in window with any resolution. This for navigation on the document. My excel is 2010.
Add the following line of code after you make the cell into a hyperlink:
Application.Goto Cells(1,1),TRUE
Replace Cells(1,1) with the appropriate cell.

Excel - Popup Asking for Text w/ Drop Down

Is it possible to have a macro that, when pressed, pops up a message box asking for a string of text, and then a drop down that has a list of categories?
All I would need it to do is take this information and save it into a cell. If so, how?
[I'm going based on Excel 2007 here, but if you're using 2003, you'll have to navigate the menu structure]
Go to the VBE (by going to the View tab, then click on Macro - creating or editing an existing one will take you there - or click Alt+F11).
Go to the Insert menu, and select Userform. Drag a textbox (the ab|icon), and a combobox onto your form. To set the textbox value to a cell when you change the combobox, create a subroutine in the code to do this by double clicking on the combobox.
Set the combobox items by using the .additem method of comboBox1 in your code. These can be delineated or grabbed from a range in your code (see here)
Within that subroutine, set the value of whatever cell you want to textbox1.Text, which is the contents of the textbox.

Resources