Quarter from Date

Godders199

Active Member
Joined
Mar 2, 2017
Messages
313
Office Version
  1. 2013
Hi, i have been playing with various codes to get the Quarter of the date in column K, displayed in column P, here is my latest attempt, could someone tell me what i am doing wrong, have googled but not found any examples of what i am looking for.


Sheets ("adviser data")
Dim lastrowcolumnA As Long
lastrowcolumnA = Range("a" & Rows.Count).End(xlUp).row
For i = 2 To lastrowcolumnA
cells(i,16).value= Range ("K"& i).Value = "Q"(month(cell.Value)+2)/3)
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
You're adding 2 to the month.

Let's assume the date you want the Quarter for is in cell A1

Ideally you are looking to extract the month from the date - =month(a1)
Then you want to divide that number by 3 - =month(a1)/3
Then, since you need to have a whole number, you need to roundup - =roundup(month(a1)/3,0)
If you want to add a Q beforehand - ="Q"&roundup(month(a1)/3,0)
 
Upvote 0
thanks, due to the size of the workbook, trying to avoid having formulas in the worksheet, i will keep playing, i am sure i will get the VBA to work .
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,651
Messages
6,126,025
Members
449,281
Latest member
redwine77

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