• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Excel Scroll Bars in User Form (VBA Code)

ianb

Member
Hi all,


Is is possiable in a user Form to have two scroll bars at are the same as the excel scroll barr.


In the user form it would allow the user to move the scroll bars to move the wroksheet up, down, left and right. If possiable this would be a neet little feature for any user form. The user form whould contain buttons and scroll bars (The controller for the Workbook or Multi Worksheet Dashboard


Regards,
 
Ian


Absolutely


You can add any number of Scroll bars to change whatever you programatically want to
 
Does any ONe have the code for placing these into the User Form that are the same as the excel scroll bars ?
 
Private Sub ScrollBar1_Change()


' What code to be the same as excel worksheet bars (Up and Down)


End Sub


Private Sub ScrollBar2_Change()


' What code to be the same as excel worksheet bars (Left and Right)


End Sub
 
Assuming ScrollBar1 is for vertical scrolling:


Place this code in Userform's initialization

[pre]
Code:
Private Sub UserForm_Initialize()
With Me.ScrollBar1
.Min = 1
.Max = Rows.Count
.Value = 1
.SmallChange = 1
End With
End Sub
And the scrollbar change event code would be:

Private Sub ScrollBar1_Change()
ActiveWindow.ScrollRow = Me.ScrollBar1.Value + Me.ScrollBar1.SmallChange
End Sub
[/pre]
You should be able to figure out the same for Horizontal (column) scrolling ;)
 
Back
Top