+ Reply to Thread
Results 1 to 2 of 2

Nested conditional statements

Hybrid View

  1. #1
    Registered User
    Join Date
    05-31-2006
    Posts
    58

    Nested conditional statements

    I am wanting to fill in a cell on sheet1 with either comment A or comment B depending on the value returned by VLOOKUP from sheet2. The comment and returned value are not the same. To achieve this I start with a for loop, use VLOOKUP, assign the returned value to a variable, test the value with If/Else statements and then assign the desired comment to the cell. The problem I am having is that the error "Compile Error: Next without For" appears when I excecute it. If I remove the If/Else statements it compiles fine. Am I not able to use the If/Else within a For loop? Is there a better way of accomplishing this?

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Use of it the else

    you can use if then else so:

    first method:
    if <condition1> then
    instructions
    elseif <condition2> then
    instructions
    elseif <condition3> then
    instructions
    else
    instructions
    endif

    or
    if <condition1> then
    instructions
    else
    instructions
    endif

    or
    if <condition1> then
    instructions
    endif

    second method - all in one row:
    if <condition> then instruction else instruction

    Regards,
    Antonio

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1