slider code

  • Thread starter Thread starter chris
  • Start date Start date
C

chris

I would like to use the slider as sort of a marker for
approaching
: > dates. It has ten ticks on the slider and I would use the ticks as
: > days. Has anybody everybody ever developed code for a
: slider or does
: > anybody know where I can view some example code?

if you are working on a sheet and go to toolbar-visual
basic-and select the button that brings up the other
selections(not the standard buttons-this button gives you
a lot more choices), one of them is a slider. This slider
has tick marks (10) and my goal is to use it(slider) as a
countdown. I would put a due date in a cell and based off
this due date, the slider would act as a countdown until
the due date is present. So in a since this would be a
calculation code(dates) of Due Date - 10days, Due Date - 9
days, Now - 8 days, etc.... with each tick mark
representing a calc between the previous.) I have looked
but have not found code related to the slider and I was
wondering how to do this or if there is was some code out
there that I could use as an example.

thank you

chris
 
Chris

You might use the Worksheet_Calculate event. With a due date in B1 and
=NOW() is F1, the code would look like this

Private Sub Worksheet_Calculate()

Dim NowDate As Date
Dim DueDate As Date

NowDate = Me.Range("F1").Value
DueDate = Me.Range("B1").Value

Debug.Print Abs(Int(NowDate - DueDate))

If DueDate - NowDate >= 11 Then
Me.Slider1.Value = Me.Slider1.Min
ElseIf NowDate > DueDate Then
Me.Slider1.Value = Me.Slider1.Max
Else
Me.Slider1.Value = Me.Slider1.Max - Int(DueDate - NowDate)
End If

End Sub

To install this code, right click on the sheet tab and choose View Code.
Paste this code into the code pane that pops up.
 
Back
Top