Excel VBA formulas for Spreadsheet by Sharath Kumar Peechara - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

Exercise 5: IF,AND Function

 

1. Create a UDF (User Defined Function)

To create this Function, execute the following steps

  1. Open Excel VBA (Altl + F11)
  2. Insert a New Module
  3. In the Project Explorer, double click on the Module
  4. Add the following code line:

Use the If Then statement in Excel VBA code lines function to act if the both 2 specific condition is met. Insert the below code in a New Module.

img9.png

This Will Create A new UDF (User Defined Function) with name Lhans(Lval, Lvxc) we Can use this As we Required. type in Excel the function As =Lhans(Lval, Lvxc), the UDF Comes up in small letter’s to differentiate itself from “tandard Excel Formula

This Code lines will create function Lhans()

In Cell C1 Type

= Lhans(A1,B1)

img10.jpg

2. Use Excel Formulas (IF,AND)

Syntax

IF(logical_test, value_if_true, [value_if_false])

AND(logical1, [logical2], ...)

=IF(AND(A1=100,B1=99),"Great","ok")