I am having a really difficult time with this excel table and was trying to use VBA as well as Excel functions to get the date formatted into Year, Month, Week but I keep running into issues.
I have the below input:
The reason Column1 looks so odd is because I was TRYING to use =MONTH([Date]) but it looks all weird and doesn't sort into the month or week it is supposed to.
Below is the expected outcome if everything were to work.
So using the Date column I want to generate 3 columns: Year, Month, Week
Any idea if I am doing something wrong in excel or if there is an easy way to do this in VBA?
Not sure where the issue is but the following formulae will give you year, month, and day. Where a1 contains a date
=year(a1)
=month(a1)
=day(a1)
Of course if you want the month to show the month in words rather than a number you can format the cell as custom and then mmm
with the date in A2 , in E2 enter:
=A2
and format as "yyyy"
In F2 enter:
=A2
and format as "mm-mmmm"
In G2 enter:
="Week " & ROUNDUP(DAY(A2)/7,0)
=YEAR([@Date])
=MONTH([@Date]) & "-" & TEXT([@Date],"mmmm")
="Week " & WEEKNUM([@Date],2)-WEEKNUM(EOMONTH([@Date],-1)+1,2)+1
and use appropriate format for each column.
You are using the right formula the only thing amiss is your column formatting as it is correctly pointed out in the comments. Follow these steps to get the desired formatting
You should get '12 - December'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.