sharky12345
Well-known Member
- Joined
- Aug 5, 2010
- Messages
- 3,422
- Office Version
- 2016
- Platform
- Windows
I'm trying to extract the year only from a cell which is formatted as custom "dd/mm/yyyy hh:mm".
I'm using this but it's giving me an incorrect value;
'Cell' refers to the cell with the date and time, in this particular example it's '01/07/2019 10:00' and this should give me 2019 but I get 1905 - anyone?
I should add that I want to achieve the result by VBA and want to avoid a formula if possible.
I'm using this but it's giving me an incorrect value;
VBA Code:
Cell.Offset(0, 16).Value = Year(Cell)
'Cell' refers to the cell with the date and time, in this particular example it's '01/07/2019 10:00' and this should give me 2019 but I get 1905 - anyone?
I should add that I want to achieve the result by VBA and want to avoid a formula if possible.