Results 1 to 5 of 5

Thread: MACRO CODE TO KNOW MONTH and QUATER

  1. #1
    Member
    Join Date
    Aug 2011
    Posts
    54
    Rep Power
    13

    MACRO CODE TO KNOW MONTH and QUATER

    Hi,

    I need a formula or Macro code to get period against Month and Quarter.
    In the period first number "1" is common(we can ignore) and next two numbers are year and last tow numbers are month which is starting from Apr to end on Mar.

    if the is period 10910 then Month will be APr-09 and Q Q1

    For your understanding i have mentioned period against Month and Quarter


    PERIOD Month Q
    10901 Apr-09 Q1
    11106 Sep-11 Q2
    11307 Oct-13 Q3
    11308 Nov-13 Q3
    11301 Apr-13 Q1
    11302 May-13 Q1
    11303 Jun-13 Q1
    11304 Jul-13 Q2
    11305 Aug-13 Q2
    11306 Sep-13 Q2
    11307 Oct-13 Q3
    11308 Nov-13 Q3
    11309 Dec-13 Q3

    Kindly help.

    Regards

    Prabhu

  2. #2
    Senior Member alansidman's Avatar
    Join Date
    Apr 2012
    Posts
    125
    Rep Power
    13
    Attached. Built a table to define the Quarters. Then using Vlookup and Concatenation, I am able to replicate your required solution.

    Alan
    Attached Files Attached Files

  3. #3
    Member
    Join Date
    Nov 2011
    Posts
    41
    Rep Power
    0
    Hi Hope this will be fine for you.


    =TEXT(RIGHT(A1,2)&"-"&MID(A1,2,2),"mmm-yy")&"-"&IF(AND(VALUE(RIGHT(A1,1))>0,VALUE(RIGHT(A1,1))<= 3),"Q1",IF(AND(VALUE(RIGHT(A1,1))>3,VALUE(RIGHT(A1 ,1))<=6),"Q2","Q3"))

    Regards
    Prince

  4. #4
    Junior Member
    Join Date
    Aug 2013
    Posts
    9
    Rep Power
    0
    Here's how I'd do it in 3 steps:

    1) Convert the code to an actual date:

    PHP Code:
    =DATEVALUE("01/" CHOOSE(MID(A1,4,2),4,5,6,7,8,9,10,11,12,1,2,3) & "/" MID(A1,2,2)) 
    Where the above is entered into cell B1 and cell A1 contains the period code.

    2) Format the date as "MMM-YY":

    PHP Code:
    =TEXT(B1,"MMM-YY"
    3) Determine the quarter (there are lots of ways to do this, this was the first that came to my head):

    PHP Code:
    ="Q" LOOKUP(MONTH(B1),{1,4,7,10},{4,1,2,3}) 
    Hope this is useful.

    Dex

  5. #5
    Member Rajan_Verma's Avatar
    Join Date
    Sep 2011
    Posts
    81
    Rep Power
    13
    ="Q"&ROUNDUP(RIGHT(A2,2)/3,0)

Similar Threads

  1. Nth Such-And-Such Day Of The Month
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 6
    Last Post: 01-02-2020, 06:48 PM
  2. Macro to change month and year on all sheet
    By Howardc in forum Excel Help
    Replies: 2
    Last Post: 08-15-2013, 05:58 PM
  3. Replies: 0
    Last Post: 07-24-2013, 11:20 PM
  4. Week Of The Month
    By Excel Fox in forum Excel and VBA Tips and Tricks
    Replies: 2
    Last Post: 02-22-2012, 08:35 PM
  5. Number of Days In A Month
    By Excel Fox in forum Excel and VBA Tips and Tricks
    Replies: 0
    Last Post: 05-14-2011, 08:00 PM

Posting Permissions

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