+ Reply to Thread
Results 1 to 3 of 3

Automatic Year Change in VBA

Hybrid View

  1. #1
    Forum Contributor dogberry's Avatar
    Join Date
    07-15-2012
    Location
    Wales, UK
    MS-Off Ver
    Excel 2010
    Posts
    624

    Automatic Year Change in VBA

    Hi


    Sub MayMonth()
    '
    ' MayMonth Macro
    '
    
    '
        Range("A5").Select
        ActiveCell.FormulaR1C1 = "1-May-2013"
        Range("A5").Select
        Selection.AutoFill Destination:=Range("A5:A35"), Type:=xlFillDefault
        Range("A5:A35").Select
    End Sub

    With the above code I have twelve of them one for each month April 2013 to March 2014. Can I get the year to change automatically for 2014 to 2015 or do I have to edit each year manually and resave. Or is there a better way.

    Many thanks

    Chris
    Last edited by Cutter; 10-28-2012 at 12:40 PM. Reason: Corrected code tags
    Click my star if I helped Thanks

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Automatic Year Change in VBA

    I can't write the code for you, but in a Excel-formula,

    =day(celladress) will gives you the day

    =month(celladress) will gives you the month

    =year(celladress) will gives you the year
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Forum Contributor dogberry's Avatar
    Join Date
    07-15-2012
    Location
    Wales, UK
    MS-Off Ver
    Excel 2010
    Posts
    624

    Re: Automatic Year Change in VBA

    Hi Oeldere

    Complete novice at this VBA but at least you have given me something else to pull my hair out over. Given your star a good kicking sorrry clicking.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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