Need help on Date formula in excel

spycein

Board Regular
Joined
Mar 8, 2014
Messages
135
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

I have a following table
QuarterActivity Start DateActivity End DateBudget Year
Q2-20175th May 201726th June 20172017

<tbody>
</tbody>





i want to populate Column No. "Quarter" with formula which will return the value as Quarter 1/Quarter 2/Quarter 3/Quarter 4 with suffix of budget year depend on the combination values of column no. "Activity Start Date" & "Activity End Date" fields.

For example,
if "Activity Start date" & "Activity End Date field contain dates between 1st Jan 2017 to 31st March 2017 then column no."Quarter" will return the value as "Quarter 1-2017"

similarly, if "Activity Start date" & "Activity End Date field contain dates between 1st April 2017 to 31st June 2017 then column no."Quarter" will return the value as "Quarter 2-2017"

Thank you so much in advance.

Regards
Shib
 
Last edited:

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi, Shib!

Are there a posibility: activity starts in Q2 and ends in Q3? and what should be written there?
 
Last edited:
Upvote 0
No.. There wont be any possibilities like that. Activities would be completed in the same quarter.
Thank you so much for the prompt reply.
 
Upvote 0
Your task can be simplified to: get activity start mounth and check it
It`s not the best, but it works for me. I think there is simplier answer, but I don`t know how to play with dates
Code:
Sub QuarterCheck()


Dim str As String
Dim i As Integer
For i = 2 To Range("b65000").End(xlUp).Row
'takes year from B column and put into D column
'uncomment if neccessary
'Range("d" & i).Value = Mid(Range("b" & i).Value, Len(Range("b" & i).Value) - 4)
'gets mounth
str = Trim(Mid(Range("b" & i).Value, 5, Len(Range("b" & i).Value) - 8))
'check mounths
        Select Case str
            Case "January", "February", "March"
                Range("a" & i).Value = "Q1-" & Range("d" & i).Value
            Case "April", "May", "June"
                Range("a" & i).Value = "Q2-" & Range("d" & i).Value
            Case "July", "August", "September"
                Range("a" & i).Value = "Q3-" & Range("d" & i).Value
            Case "October", "November", "December"
                Range("a" & i).Value = "Q4-" & Range("d" & i).Value
            Case Else
            '
        End Select
Next i

End Sub
 
Last edited:
Upvote 0
Hi S_Wish,

Thank you so much for the reply.

Could you please attach an excel sheet consisting with the above code, so that i can get a clarity on the formula and also could check how does it work.

Thanks a ton.
 
Upvote 0
it is not allowed to attach files. all you need is to put that code into a VBA module, and run it.
if you do not know how to open vba - google.
 
Upvote 0
Hi, here is a formula you can try - this assumes that the dates are true excel dates (not text).


Excel 2013
ABCD
1QuarterActivity Start DateActivity End DateBudget Year
2Q2-201705-May-1726-Jun-172017
Sheet1
Cell Formulas
RangeFormula
A2="Q"&ROUNDUP(MONTH(B2)/3,0)&"-"&D2
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top