Results 1 to 4 of 4

Day and Month Spinner VBA

Threaded View

ntate Day and Month Spinner VBA 08-20-2014, 02:55 PM
xladept Re: Day and Month Spinner VBA 08-20-2014, 04:37 PM
ntate Re: Day and Month Spinner VBA 08-20-2014, 06:52 PM
xladept Re: Day and Month Spinner VBA 08-20-2014, 06:55 PM
  1. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Day and Month Spinner VBA

    Hi N,

    Try:

    Private Sub SpinButton1_SpinDown()
    Dim D As Date, N As Integer
    On Error Resume Next
    If Range("o1") = 1 Then
    Range("o2").Value = Range("o2").Value - 1
    Else
    D = Range("P2").Value
    Select Case Month(D)
    Case 3: N = 29
    If Year(D) Mod 4 Then N = 28
    Case 5, 7, 10, 12
    N = 30
    Case Else: N = 31
    End Select
    Range("o2").Value = Range("o2").Value - N
    End If
    Calculate
    End Sub
    
    Private Sub SpinButton1_SpinUp()
    On Error Resume Next
    Dim D As Date, N As Integer
    If Range("o1") = 1 Then
    Range("o2").Value = Range("o2").Value + 1
    Else
    D = Range("P2").Value
    Select Case Month(D)
    Case 2: N = 29
    If Year(D) Mod 4 Then N = 28
    Case 4, 6, 9, 11
    N = 30
    Case Else: N = 31
    End Select
    Range("o2").Value = Range("o2").Value + N
    End If
    Calculate
    End Sub
    Last edited by xladept; 08-20-2014 at 06:04 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Auto instert Month names for This month, Last month and Next month
    By hemal89 in forum Word Programming / VBA / Macros
    Replies: 4
    Last Post: 12-10-2013, 12:01 PM
  2. Excel 2007 : Add a Spinner
    By cd3atm in forum Excel General
    Replies: 1
    Last Post: 11-03-2010, 12:13 AM
  3. Spinner and Dates
    By cybercab in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-13-2006, 01:39 PM
  4. [SOLVED] Spinner
    By Maureen in forum Excel General
    Replies: 2
    Last Post: 05-23-2005, 10:06 AM
  5. [SOLVED] Spinner-requiring Spinner buttons
    By Greg Robinson via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-26-2005, 07:34 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1