Setting value of linked cell for a Scroll Bar

mxweb

New Member
Joined
Apr 26, 2014
Messages
3
Hello, I am trying to dynamically set the value of the linked cell for a Scroll Bar. I dont mind if the scroll bar is form type or active x type.

Basically I have a column with figures in each cell moving down:

15
19
23
56

I have a scroll bar

I want the scroll bar to change the value in the active cell.

So if I select the cell with value 15 then I want that to change when I change the scroll bar. If I then select 56, I want that value to change.

Been struggling with this so any help would be appreciated.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
OK I just figured it out - for anyone interested (it took me all nite to sort this one!) here is what I did:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ScrollBar1.LinkedCell = ActiveCell.Address
End Sub

Pretty simple really.

But, does anyone know how to make it so it only sets the linked cell when the active cell address is within a defined range (ie, only when they click on my data range)
 
Upvote 0
Try

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("A1:A5")) Is Nothing Then ScrollBar1.LinkedCell = Target.Address
End Sub

Note that I changed ActiveCell to Target.
 
Upvote 0
Hi, thanks for that, but when I clicked outside the range it still changed the last active cell within range if I used the scroll bar. Maybe I did something wrong?

What I settled on was (and it is probably noob messy, but main thing is it works) disabling the scroll bar when user clicked outside range, and enabled it when user clicked inside range, and setting the linked cell:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim rngTest As Range
Set rngTest = Application.Intersect(ActiveCell, Range("B6:B10"))
If rngTest Is Nothing Then
ScrollBar1.Enabled = False
Else

ScrollBar1.LinkedCell = ActiveCell.Address
ScrollBar1.Enabled = True
End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

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