Adjust a Scroll bar to fill in a range perfectly

H

hotbero

Hi!!!
Sorry because I do not know the english name.
if you go to view/toolbox. there are many different controls. one of
then is similar to the ScrollBar located in ActiveX controls, "I
don't know the name anyway" my question is:"


How can Adjust this "ControlBox" to fill in a range "say
Range("C3:F3") perfectly.

My problem comes because the Scrollbox in ActiveX controls has a
property to change the resize the control size with the cells, but the
"ScrollBox from the Toolbox, again this is not a ScrollBox, but looks
similar, and I don't know the Englixh name, does not have this
property enabled.

So I need to use VBA to adjust this "ScrollBox to a Range.

The Same way, if I get a Shape and or one Image, how can Adjust this
images size to fill perfectly in a Range, useful if I want to adjust
my company's logotipe in a Range, some Logotipes are to big others so
small, I would like to create a Template, with a botton to get the
image from a File and once is teken "Already done", adjust it to the
range named Company_logotipe.

This is the same question but for a Shape and/or image!


Many Thanks!!!
 
B

Bill Renaud

Public Sub SetScrollBar()
Dim ws As Worksheet
Dim rng As Range
Dim sb1 As OLEObject

Set ws = ActiveSheet
Set rng = ws.Range("$C$3:$F$3")
Set sb1 = ws.OLEObjects("ScrollBar1")

With sb1
'Set the upper-left corner of the scroll bar to the range.
.Top = rng.Top
.Left = rng.Left

'Now set the height and width of the scroll bar.
.Height = rng.Height
.Width = rng.Width
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top