+ Reply to Thread
Results 1 to 4 of 4

VBA code to name the worksheet with quarter end date automatically

  1. #1
    Registered User
    Join Date
    09-21-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    3

    VBA code to name the worksheet with quarter end date automatically

    VBA code to name the worksheet with quarter end date automatically
    Hello everyone

    i am new to VBA codings.. can anyone please help?? i have been trying to figure this out on my own for the last two days and it's not going anywhere. Can anyone correct my codes or suggest better codes for this?

    I am trying to figure out codes to duplicate an existing worksheet with the worksheet name " XYZ report Q2 2016" and i want this sheet to be updated for Q3 with the worksheet name "XYZ report Q3 2016"

    Below codes are what i have done so far and they are not working.
    1. Sheet(2) Cell C4 has the last quarter date 30 June 2016
    2. Sheet(1) is the report that i want to duplicate and that i wanted it to be updated for Q3




    Sub Duplicatereport()
    '
    ' Duplicatereport Macro
    '
    Dim mydate As Date
    Dim mydate2 As Date
    mydate = Sheets(2).Range("c4")
    mydate2 = DateSerial(Year(mydate), Month(mydate) + 3, Day(mydate))


    Sheets("XYZ Q2 2016").Copy after:=Sheets(2)
    ActiveSheet.Name = Format(mydate2, "mm yyyy")

    End Sub

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: VBA code to name the worksheet with quarter end date automatically

    Hi hyunee
    Welcome to the forum..
    Please put the codes between code tags

    Try this code
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Registered User
    Join Date
    09-21-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    3

    Re: VBA code to name the worksheet with quarter end date automatically

    Thank you!

    Now i realised that i still have to keep updating manually the cell c4. is there anyway i can make the cell to be updated automatically to next qtr end date?

    For example, next December quarter, i will have to update C4 to 30 September 16 for my VBA codes "mydate2" to be updated to 30 December 16

    can you please suggest a way to do that if any?

    Thank you.

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: VBA code to name the worksheet with quarter end date automatically

    You can add this line at the end of the code to update Cell C4
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Using SumProduct for dates inclusive of Year to Date, Month to date, Quarter to Date
    By cartica in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-26-2014, 04:22 PM
  2. Quarter tabs formatted automatically in ascending order
    By cwcpoppa in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-28-2014, 02:29 PM
  3. [SOLVED] Will automatically show the quarter depending on the date
    By Elainefish in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-17-2013, 04:23 AM
  4. Replies: 2
    Last Post: 01-04-2012, 09:15 AM
  5. Replies: 9
    Last Post: 12-27-2011, 12:52 AM
  6. Date doesn't appear automatically when running date code
    By James12 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-21-2009, 05:20 PM
  7. [SOLVED] Automatically add data by quarter
    By cpope in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-12-2008, 01:59 PM
  8. update VBA code automatically when worksheet changes
    By winamd72 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-30-2008, 06:37 AM

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