Excel VBA OleObjects

Maka

New Member
Joined
Feb 11, 2005
Messages
1
HI, I am trying to insert form my code a scrollbar conected to a specific range. When doing it form Excel I only have to insert form the Vba toolbar the scrollbar, right clik and give, the properties I need to specify ( linkedcell, max, min) but when I do this from my code an error appears. Here is what i tried:

Sub Macro1(MyRange As Range)
Dim MyObject As OLEObject
ActiveSheet.OLEObjects.Add(ClassType:="Forms.ScrollBar.1").Select
Set MyObject = Selection
With MyObject
.LinkedCell = MyRange.Offset(, -1)
.Top = MyRange.Top
.Left = MyRange.Left
.Width = MyRange.Width
.Height = MyRange.Height
.Max = 100
.Min = 0
End With
End Sub

the problem is the linked cell doesnt link, the properties left, top , width and height do work but max and min don't work
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,207,172
Messages
6,076,919
Members
446,241
Latest member
Nhacai888b

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