![]() |
show the current year
is there a way for a macro to insert the current year
into a cell. i have some formulas that calculate holidays from an excel book, and they all have to refer back to a cell containing the year. however when i tried to put in a function such as =TODAY() in a cell and formatted it as custom "yyyy" it still displays 1/13/04 and the formulas return a #NUM error. so i think a macro might be able to just input "2004" into a cell somehow. i have been playing with some VBA functions, but i am sure that it is just something i havent learned yet. TIA...spence |
show the current year
Spence,
Try =YEAR(TODAY()) -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "spence" wrote in message ... is there a way for a macro to insert the current year into a cell. i have some formulas that calculate holidays from an excel book, and they all have to refer back to a cell containing the year. however when i tried to put in a function such as =TODAY() in a cell and formatted it as custom "yyyy" it still displays 1/13/04 and the formulas return a #NUM error. so i think a macro might be able to just input "2004" into a cell somehow. i have been playing with some VBA functions, but i am sure that it is just something i havent learned yet. TIA...spence |
show the current year
Hi Spence!
Is this what you wanted to do: Sub test() ActiveCell.Formula = "=TODAY()" ActiveCell.NumberFormat = "yyyy" End Sub -- Regards Norman Harker MVP (Excel) Sydney, Australia Excel and Word Function Lists (Classifications, Syntax and Arguments) available free to good homes. "spence" wrote in message ... is there a way for a macro to insert the current year into a cell. i have some formulas that calculate holidays from an excel book, and they all have to refer back to a cell containing the year. however when i tried to put in a function such as =TODAY() in a cell and formatted it as custom "yyyy" it still displays 1/13/04 and the formulas return a #NUM error. so i think a macro might be able to just input "2004" into a cell somehow. i have been playing with some VBA functions, but i am sure that it is just something i havent learned yet. TIA...spence |
All times are GMT +1. The time now is 12:35 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com