ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   slider code (https://www.excelbanter.com/excel-programming/280188-slider-code.html)

Chris

slider code
 
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

Dick Kusleika[_3_]

slider code
 
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.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"chris" wrote in message
...
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





All times are GMT +1. The time now is 09:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com