FrustratedEland
New Member
- Joined
- Jul 12, 2022
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
Back again with these pesky scrollbars.
So, I am concatenating the scrollbar name to get the right scrollbar, and then trying to set the scrollbar to a value. Once more, I am running into errors. This is a simplified version of what I am trying to do.
The scrollbar is called SCBlue in this example, and A1 contains 'Blue'. B1 contains the position that I would like to set the scrollbar to.
As a check, everything works fine 'manually', if I change lines 7 to 9 to
SCBlue.Value = Position
Grateful as always for any help!
So, I am concatenating the scrollbar name to get the right scrollbar, and then trying to set the scrollbar to a value. Once more, I am running into errors. This is a simplified version of what I am trying to do.
The scrollbar is called SCBlue in this example, and A1 contains 'Blue'. B1 contains the position that I would like to set the scrollbar to.
VBA Code:
Private Sub test()
Dim Bar As Object
Dim Position As Long
Category = Sheet1.Range("A1")
Barname = ("SC" & Category)
Position = Sheet1.Range("B1").Value
Set Bar = Sheets("Sheet1").OLEObjects("Barname").Object
With Bar.Value = Position
End With
End Sub
As a check, everything works fine 'manually', if I change lines 7 to 9 to
SCBlue.Value = Position
Grateful as always for any help!