excel-vba UDF - Hello World


Example

  1. Open Excel
  2. Open the Visual Basic Editor ( see Opening the Visual Basic Editor )
  3. Add a new module by clicking Insert --> Module :

enter image description here

  1. Copy and Paste the following code in the new module :
Public Function Hello() As String
'Note: the output of the function is simply the function's name
Hello = "Hello, World !"
End Function

To obtain :

enter image description here

  1. Go back to your workbook and type "=Hello()" into a cell to see the "Hello World".

enter image description here