A function in Excel is a set of pre-defined lines of code that performs a specific task on data within a worksheet. For example, the AVERAGE(A1:A10) function is designed to calculate the average of the values ​​in the range A1:A10.