how to set controlsource to a scrolbar inside a userform?

marik9581

New Member
Joined
Jun 1, 2018
Messages
8
hi

i have a userform with a scrollbar which i need to set to a range of cells. how do i do it?
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
For example:
Code:
Userform1.ScrollBar1.ControlSource = "Sheet1!K5"
This sets the controlsource for SrollBar1 in Userform1 to cell K5 in Sheet1

bye
 
Upvote 0
in the worksheet itself i placed a button with this code:
Code:
Sub brands()    UserForm1.ScrollBar1.ControlSource = Sheets("config").Range("A2")
    UserForm1.Show
End Sub

in the userform code i used:

Code:
Private Sub UserForm_Activate()    Dim xlsettings As Worksheet
    Dim xlworkbook As Workbook
    Dim rngexternal As Range
    Dim lastrow As Long
    
    Set xlworkbook = Application.Workbooks("data.xlsm")
    Set xlsettings = xlworkbook.Worksheets("config")
    With xlsettings
        lastrow = .Cells(.Rows.Count, "A").End(xlUp).Offset(0, 0).Row
    End With
Set rngexternal = xlsettings.Range("a2:a" & CStr(lastrow))
    
End Sub

the same happends when i try to set the controlsource inside the userform code or in the moudle itself.
 
Upvote 0
Does this look like what I suggested?
UserForm1.ScrollBar1.ControlSource = Sheets("config").Range("A2")
:confused:


Code:
UserForm1.ScrollBar1.ControlSource = "config!A2"
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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