1、 首先,打开 Excel,并按下 Alt + F 11 进入 Visual Basic for Applications(VBA)编辑器。2、 在 VBA 编辑器中,选择插入 -> 模块,然后在模块中插入以下代码:Function CalculateAge(id As String) As Integer Dim birthDate As Date birthDate = DateSerial(Mid(id, 7, 4), Mid(id, 11,...
2、 在 VBA 编辑器中,选择插入 -> 模块,然后在模块中插入以下代码: Function CalculateAge(id As String) As Integer Dim birthDate As Date birthDate = DateSerial(Mid(id, 7, 4), Mid(id, 11, 2), Mid(id, 13, 2)) CalculateAge = DateDiff("yyyy", birthDate, Date)End Function 提示:如果...
We used “y” and “ym” as units to calculate the year and month. Press ENTER to get the age value in years and months. Drag down the Fill Handle tool to AutoFill the formula for the rest of the cells. You will get the age values calculated using the DATEDIF function. Method 2 ...
2) If you want to get the next year’s age based on the birthdate, just add 1 in the formula such as =DATEDIF(B2,TODAY(),"y")+1. 3.12 Calculate age in years, month and days format by given birthday If you want to calculate age based on a given birthdate, and...
Top Methods to Calculate Age in Excel In Excel, one can calculate the exact age of a person using different techniques. Age can be calculated in years, months, days, hours, and so on. For calculating the age, the beginning and ending dates need to be specified. Besides age, one can ca...
To calculate age in the format of Year + Month + Day, combine three DATEDIF formulas in Excel, each with a different unit argument. Select an empty cell to display the age, input the formula provided below, and hit the Enter key. Then, click on the cell with the result and drag its...
Calculate Age between Two Dates You may need to calculate age between two specified dates rather than using today’s date as the end date as shown in all examples so far. Reasons for this include, wanting to calculate someone’s age at a given date, or wanting to calculate the time taken...
Method 2 –Combining DATEDIF and TODAY Functions to Calculate Current Age If you want to know a person’s actual age, you can find out how many years, months, and days have passed since their birth. TheDATEDIFfunction should be combined into a single formula as shown below in step1. ...
The age calculator feature in Excel is a useful tool that allows you to calculate the age of a person. In this guide, we will walk you through the process of using formulas to calculate age in Excel, both in years, months, and days, as well as on a specific date. In addition, we...
How to Calculate Age in Months You can use theDATEDIFfunction to find someone's age in months, too. For this example, again, we'll use the data from the above spreadsheet, which looks like this: In this spreadsheet, we'll click the C2 cell where we want to display the age in months...