Question: how do i create a user defined function in excel vba?
Answer: User defined functions need to be placed into a module. Open the Visual Basic Editor and click Insert, Module. ... 
Function SUMEVENNUMBERS(rng As Range) The name of our Function is SUMEVENNUMBERS. ... 
Dim cell As Range. ... 
For Each cell In rng. ... 
If cell.Value Mod 2 = 0 Then. ... 
SUMEVENNUMBERS = SUMEVENNUMBERS + cell.Value. ... 
End Function.