The easiest way to think of a sub vs a function is that a function can return a value and a sub cannot.
Sub can be thought of as a small program that performs some action that is contained within the program. Subs can be used to update a cell or perform an import and calculation, but the result can't be returned to another sub or function. Another thing to note is that a sub (or macro) cannot be accessed directly by a cell reference. For example, when a cell is used to show today's date, =Today(), that formula is also a built-in function, not a sub.
Function is similar similar to a sub, except that a function can return a value. It may be easier to think of a function as similar to a formula in excel. You can provide the function the necessary inputs and the function returns the desired value. You can build a custom function for just about any action and then access that function from either a call from a macro, or a direct reference from a cell.