Create your own custom Excel function

If you want to make your own function as the built-in ones SUM() for example you go to:
Developer tab and click on the Visual Basic icon

in the new window of Microsoft Visual Basic for Applications, you click on Insert > Module

Now you can write your code, for example, if you want to write a function that extracts the url of a link in a cell, the code could be like this

Function GetURL(cell As Range)
    GetURL = cell.Hyperlinks(1).Address
End Function

Now, you can use this function “GetURL” as any ordinary function in Excel.

Note that if you want to save the file, you have to save it as Excel Macro-Enabled Workbook (*.xlsm)

Visit this page for more information:

https://support.microsoft.com/en-us/office/create-custom-functions-in-excel-2f06c10b-3622-40d6-a1b2-b6748ae8231f