Here is what I have come up with:
Sub Macro1()
Set slider = Sheets("Sheet1").Shapes("Flowchart: Sort 1")
LeftPos = Range("F5").Left
RightPos = Range("F5").Left + Range("F5").Width
Value = Range("G3").Value
If Value < Range("E5").Value Or Value > Range("G5").Value Then
ActiveSheet.Shapes.Range(Array("Flowchart: Sort 1")).Select
Selection.ShapeRange.Fill.Visible = msoFalse
Selection.ShapeRange.Line.Visible = msoFalse
GoTo EndSub
Else
ActiveSheet.Shapes.Range(Array("Flowchart: Sort 1")).Select
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Solid
End With
With Selection.ShapeRange.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0
End With
End If
Position = LeftPos + ((Value - Range("E5").Value) / (Range("G5").Value - Range("E5").Value)) * (RightPos - LeftPos)
slider.Height = Range("F5").Height
slider.Top = Range("F5").Top
slider.Left = Position - (0.5 * slider.Width)
EndSub:
Range("G3").Select
End Sub
It is set to automatically run when G3 is selected. E5 and G5 are the min and max.
Another cool idea would be to create a color gradient that changes the slider depending on position. I think this would be similar to finding the position but it seems a bit daunting for me.
Bookmarks