ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   calendar spinbutton (https://www.excelbanter.com/excel-programming/450469-calendar-spinbutton.html)

Avexon

calendar spinbutton
 
Hello, I make 100 years calendar and i want month and year change with active x spinbutton. in cell "B4" is number of month (1 to 12) and in cel "H4" is year. one spin buton for month change and one for year change. if in cell with month (B4) is 12 and i click to spin up (for month) i want to jump to 1 (not to 13) and year (in cell h4 ) +1 and if i click to spin down and in cell "b4" is 1 i want to jump 12 (not to 0) and decrease year by 1 ("h4")-1


i have code for jump from 12 to 1 and 1 to 12 but dont know how increase and decrease year.


my code:
Code:

Private Sub SpinButton1_SpinDown()
Range("B4").Value = Range("B4").Value - 1
    If [B4] = 0 Then [B4] = 12
End Sub


Private Sub SpinButton1_SpinUp()
Range("B4").Value = Range("B4").Value + 1
    If [B4] = 13 Then [B4] = 1
End Sub


Claus Busch

calendar spinbutton
 
Hi,

Am Thu, 27 Nov 2014 15:32:49 +0000 schrieb Avexon:

Hello, I make 100 years calendar and i want month and year change with
active x spinbutton. in cell "B4" is number of month (1 to 12) and in
cel "H4" is year. one spin buton for month change and one for year
change. if in cell with month (B4) is 12 and i click to spin up (for
month) i want to jump to 1 (not to 13) and year (in cell h4 ) +1 and if
i click to spin down and in cell "b4" is 1 i want to jump 12 (not to 0)
and decrease year by 1 ("h4")-1


in properiy window for the spinbutton set min to 0 and max to 13 and
linked cell to Sheet1!B4:

Private Sub SpinButton1_SpinDown()
With ActiveSheet
If .SpinButton1 < 1 Then
.SpinButton1 = 12
.Range("H4") = .Range("H4") - 1
End If
End With
End Sub

Private Sub SpinButton1_SpinUp()
With ActiveSheet
If .SpinButton1 12 Then
.SpinButton1 = 1
.Range("H4") = .Range("H4") + 1
End If
End With
End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional

Avexon

Thank you!


All times are GMT +1. The time now is 02:52 AM.

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