RockandGrohl
Well-known Member
- Joined
- Aug 1, 2018
- Messages
- 790
- Office Version
- 365
- Platform
- Windows
I'm doing this at the moment, but it's just a messy loop for simpletons:
It's just to replace a column (that may or may not have blanks) that contains dates with the year. I can't format because the date will still exist as "04/10/2020" - it needs to just be an integer of "2020"
Is there a better way of doing it? Takes a few seconds to run the loop but I'm sure it can be instant. Thanks.
VBA Code:
Do Until Cells(ActiveCell.Row, "A").Value = ""
If ActiveCell.Value <> "" Then
ActiveCell.Value = Year(ActiveCell.Value)
ActiveCell.NumberFormat = general
End If
ActiveCell.Offset(1, 0).Activate
Loop
It's just to replace a column (that may or may not have blanks) that contains dates with the year. I can't format because the date will still exist as "04/10/2020" - it needs to just be an integer of "2020"
Is there a better way of doing it? Takes a few seconds to run the loop but I'm sure it can be instant. Thanks.