bryanrobson
New Member
- Joined
- Aug 19, 2022
- Messages
- 21
- Office Version
- 365
- Platform
- Windows
I have some date formulas in 3 cells which work but I want to put them into VBA code. My VBA is limited and I'm trying to pick up things. It doesnt like what I have done
=DATE(YEAR(P5),MONTH(P5)*1,1)
=DATE(YEAR(P5), MONTH(P5)-12, 1)
=DAY(EOMONTH($P$5,0))
VBA code
Range("R5").Value = DateSerial(Year(P5), Month(P5) * 1, 1)
Range("S5").Value = DateSerial(Year(P5), Month(P5) - 12, 1)
Range("U5").Value = Day(DateSerial(Year(P5), Month(P5) + 1, 1) - 1)
P5 has the date in it format dd/mm/yyyy
Thanks in advance
=DATE(YEAR(P5),MONTH(P5)*1,1)
=DATE(YEAR(P5), MONTH(P5)-12, 1)
=DAY(EOMONTH($P$5,0))
VBA code
Range("R5").Value = DateSerial(Year(P5), Month(P5) * 1, 1)
Range("S5").Value = DateSerial(Year(P5), Month(P5) - 12, 1)
Range("U5").Value = Day(DateSerial(Year(P5), Month(P5) + 1, 1) - 1)
P5 has the date in it format dd/mm/yyyy
Thanks in advance