Spin Button to increment or decrement the date in cell A1

  • Thread starter Thread starter Pal
  • Start date Start date
P

Pal

How can I used the Spin Button to increment or decrement the date in cell A1
format(dd/mm/yyyy)
I went thru the help but I could not find the location to change the spinup
and spindown properties.
Thanks
Pal
 
wks is undefined from what you have shown

Private Sub SpinButton1_SpinUp()
me.Range("g4") = me.Range("g4") + 1
End Sub

Private Sub SpinButton1_SpinDown()
me.Range("g4") = me.Range("g4") - 1
End Sub

Worked fine for me given that G4 is on the same sheet as the spinbutton.
 
Thank Tom
That worked

But every time I change it manually, then hit the spinner it resets to
01/01/1900

Pal
 
Dates are stored as the number of days since 1/1/1900. The value you show
would indicate a zero is being stored in the cell (or a decimal number less
than 1 - but more than likey, a zero). Format the cell as general to see
the serial number stored in the cell.

How it gets there, I can't say. I had no trouble manually editing G4 using
the code I posted. It works fine for me. You don't have the spinbutton
linked to G4 do you. You should only have code affect the value of G4.

Regards,
Tom Ogilvy
 
Back
Top