USER Defined - functIOS - Excel
USER Defined - functIOS - Excel
USER Defined - functIOS - Excel
com
VBE will open with three windows inside the VBE environment. They are,
1. The Project Window,
2. The Code Window (2), and
3. The Properties Window (3).
We can resize the windows by left-clicking where the resize icons, holding
and moving sideways or up and down.
The VBE creates a New Module (Module1) inside the project (See Project
window).
Note: If we record any macro, the macro will be stored inside the module
only.
Every custom function (UDF) begins with the key word ‘Function’ followed by
the name of the function and parentheses. It ends with the key word ‘End
Function’.
VBE will automatically insert this End Function key word, once we hit the
enter key after typing the function, function name and the parentheses.
Type the code inside the code windows as given in the below picture.
4
Explanation
1. ContractTDS is the name of the function
2. Amount & Contractor are called variables
3. First step, we need to identify the type of the contractor. If the user
enters the type of the contractor as ‘others’, our function will pick the
TDS Rate as 2%. Otherwise, it will pick 1% as rate of TDS.
4. Second step, we need to identify whether the single payment amount
is less than 30000 or not. If the user enters amount as 30000 or more,
system will apply TDS rate on the Payment amount. Otherwise, it will
consider ContractTDS as Nil.
5. Finally, the function will return the result.
Verification:
1. Close the VBE window. Go to the excel and select any worksheet.
2. Select B1 and type ‘others’
3. Select B2 and type ‘35000’
4. Enter our formula as given in the below picture.