Consulting

Results 1 to 3 of 3

Thread: Solved: Previous Month

  1. #1
    VBAX Contributor
    Joined
    Apr 2008
    Posts
    136
    Location

    Solved: Previous Month

    I would like some vba code How do I enter in a cell some vba code that shows the previous month and current year. Example if doing today it would be
    Feb- 2010.

    Many Thanks

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]Sub LastMonth()
    ActiveCell = Format(DateSerial(Year(Date), Month(Date) - 1, 1), "mmm-yy")
    End Sub
    [/VBA]

    or
    =DATE(YEAR(TODAY()),MONTH(TODAY())-1,1)
    and format as required.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Contributor
    Joined
    Apr 2008
    Posts
    136
    Location
    perfect thanks, !!

Posting Permissions

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