Have you tried Googling for "excel vba using functions in code"?
You will get plenty of results, such as
Excel VBA Function and Sub - Easy Excel Macros
and
VBA VLOOKUP: How to Use Worksheet Functions in VBA [2020]
and
Excel VBA Function Tutorial: Return, Call, Examples
etc.