Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default Spinner and Date What the heck is happening?

It seemed pretty simple, drop a spinner on the worksheet, stick some code
into the spinup and spindown to add or subtract 1 to/from the value in a
certain cell. Just because the value is a date shouldn't make any difference,
after all it's just another number.
So why does this retrieve the value of Zero everytime it fires? Yea, I put
the current date into the cell F5, then when I click on the spinup the value
in F5 becomes Zero! And of course it puts the Zero value +1 back into the
cell.
What the heck is heck is going on?! :/)

Private Sub SpinButton1_SpinDown()
Range("F5").Value = DateValue(Range("F5").Value) - 1
End Sub

Private Sub SpinButton1_SpinUp()
Range("F5").Value = DateValue(Range("F5").Value) + 1
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Spinner and Date What the heck is happening?

Not sure, your code works just fine for me.

Is F5 formatted to be a date? This code works just as well too,

Private Sub SpinButton1_SpinDown()
Range("F5").Value = Range("F5").Value - 1
End Sub
Private Sub SpinButton1_SpinUp()
Range("F5").Value = Range("F5").Value + 1
End Sub


h.

"mikebres" wrote:

It seemed pretty simple, drop a spinner on the worksheet, stick some code
into the spinup and spindown to add or subtract 1 to/from the value in a
certain cell. Just because the value is a date shouldn't make any difference,
after all it's just another number.
So why does this retrieve the value of Zero everytime it fires? Yea, I put
the current date into the cell F5, then when I click on the spinup the value
in F5 becomes Zero! And of course it puts the Zero value +1 back into the
cell.
What the heck is heck is going on?! :/)

Private Sub SpinButton1_SpinDown()
Range("F5").Value = DateValue(Range("F5").Value) - 1
End Sub

Private Sub SpinButton1_SpinUp()
Range("F5").Value = DateValue(Range("F5").Value) + 1
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Spinner and Date What the heck is happening?

Mike,

Dates are just formatted numbers, with 1 being one day. This should work:

Private Sub SpinButton1_SpinDown()
Range("F5").Value = Range("F5").Value - 1
End Sub

Private Sub SpinButton1_SpinUp()
Range("F5").Value = Range("F5").Value + 1
End Sub

HTH,
Bernie
MS Excel MVP


"mikebres" wrote in message
...
It seemed pretty simple, drop a spinner on the worksheet, stick some code
into the spinup and spindown to add or subtract 1 to/from the value in a
certain cell. Just because the value is a date shouldn't make any difference,
after all it's just another number.
So why does this retrieve the value of Zero everytime it fires? Yea, I put
the current date into the cell F5, then when I click on the spinup the value
in F5 becomes Zero! And of course it puts the Zero value +1 back into the
cell.
What the heck is heck is going on?! :/)

Private Sub SpinButton1_SpinDown()
Range("F5").Value = DateValue(Range("F5").Value) - 1
End Sub

Private Sub SpinButton1_SpinUp()
Range("F5").Value = DateValue(Range("F5").Value) + 1
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default Spinner and Date What the heck is happening?

Well now that is just plain wierd. I went back and tried it again and it
worked just fine. Sometimes I think the computer doesn't like me.

Thanks folks.

"Bernie Deitrick" wrote:

Mike,

Dates are just formatted numbers, with 1 being one day. This should work:

Private Sub SpinButton1_SpinDown()
Range("F5").Value = Range("F5").Value - 1
End Sub

Private Sub SpinButton1_SpinUp()
Range("F5").Value = Range("F5").Value + 1
End Sub

HTH,
Bernie
MS Excel MVP


"mikebres" wrote in message
...
It seemed pretty simple, drop a spinner on the worksheet, stick some code
into the spinup and spindown to add or subtract 1 to/from the value in a
certain cell. Just because the value is a date shouldn't make any difference,
after all it's just another number.
So why does this retrieve the value of Zero everytime it fires? Yea, I put
the current date into the cell F5, then when I click on the spinup the value
in F5 becomes Zero! And of course it puts the Zero value +1 back into the
cell.
What the heck is heck is going on?! :/)

Private Sub SpinButton1_SpinDown()
Range("F5").Value = DateValue(Range("F5").Value) - 1
End Sub

Private Sub SpinButton1_SpinUp()
Range("F5").Value = DateValue(Range("F5").Value) + 1
End Sub




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How the heck? Dave Excel Worksheet Functions 6 April 8th 08 03:34 AM
Hide and unhide...what the heck!!?? LeahT Excel Discussion (Misc queries) 6 March 21st 08 02:10 AM
What the heck is wrong here? [email protected] Excel Programming 1 January 5th 07 06:20 PM
Spinner box in Excel to adjust date Mrebisz3154 Excel Worksheet Functions 4 October 28th 05 11:32 PM
Date Control using Spinner Stan Excel Programming 6 October 11th 04 11:17 AM


All times are GMT +1. The time now is 05:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"