Results 1 to 2 of 2

Thread: IIF Function in VBA

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    8
    Rep Power
    0

    IIF Function in VBA

    The Immediate If Function
    The Immediate If function has the syntax:
    IIf(Expression, TruePart, FalsePart)

    If Expression is True, then the function returns TruePart. If Expression is False, the
    function returns FalsePart. For instance, the following code displays a dialog indicating
    whether or not the first row in the active worksheet is empty:

    Code:
    Dim rng As Range
    Set rng = ActiveSheet.Rows(1)
    MsgBox IIf(IsEmpty(ActiveSheet.Cells(1, 1)), _
    "Cell is empty", "Cell is not empty")
    It is very important to note that the Immediate If function always evaluates both TruePart and
    FalsePart, even though it returns only one of them. Hence, we must be careful about
    undesirable side effects.
    Last edited by Admin; 12-01-2011 at 08:51 PM. Reason: code tag added

  2. #2
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi Nishant,

    Welcome to ExcelFox !!

    Keep share the tips !
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

Similar Threads

  1. UDF (user defined function) replacement for Excel's DATEDIF function
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 21
    Last Post: 03-07-2015, 09:47 PM
  2. IsDate() Function : VBA
    By Transformer in forum Tips, Tricks & Downloads (No Questions)
    Replies: 0
    Last Post: 06-03-2013, 10:00 PM
  3. CHR() Function VBA
    By Transformer in forum Tips, Tricks & Downloads (No Questions)
    Replies: 1
    Last Post: 05-20-2013, 08:50 AM
  4. CurDir() function VBA
    By Transformer in forum Tips, Tricks & Downloads (No Questions)
    Replies: 0
    Last Post: 05-17-2013, 12:32 AM
  5. STRCONV Function (VBA)
    By Transformer in forum Tips, Tricks & Downloads (No Questions)
    Replies: 0
    Last Post: 05-17-2013, 12:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •