+ Reply to Thread
Results 1 to 4 of 4

Multiple if statements in a for loop

  1. #1
    Registered User
    Join Date
    04-18-2019
    Location
    Melbourne
    MS-Off Ver
    2010
    Posts
    2

    Multiple if statements in a for loop

    Hi

    I've tried different methods to include multiple if statements in a for loop but they don't seem to work and I'm not sure what the problem is. I keep getting the message "End If without block If" I have a different condition for each of the statements. Can someone help me please

    For Z = 4 To lastrowG
    If WorksheetFunction.isblank(data.Cells(Z, 147)) Then data.Cells(Z, 148).clearcontent

    ElseIf data.Cells(Z, 154) = "F" Or data.Cells(Z, 154) = "FI" Or data.Cells(Z, 154) = "TC" Then data.Cells(Z, 148).clearcontent

    ElseIf data.Cells(Z, 147) = "Duplicate" Then data.Cells(Z, 148).clearcontent

    ElseIf data.Cells(Z, 148) = "Yes" And WorksheetFunction.isblank(data.Cells(Z, 159)) Then data.Cells(Z, 159) = "NA"

    End If
    Next Z
    Last edited by clauz_vi67; 04-18-2019 at 09:23 PM.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Multiple if statements in a for loop

    Hi there,

    If by "they don't seem to work" you mean that a Syntax Error message is generated then try:

    Please Login or Register  to view this content.
    The worksheet function "IsBlank" doesn't seem to be available in VBA.

    I'm assuming that your workbook contains a worksheet whose CodeName (not Tab name) is "data"


    Hope this helps.

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    04-18-2019
    Location
    Melbourne
    MS-Off Ver
    2010
    Posts
    2

    Re: Multiple if statements in a for loop

    Hi

    I keep getting the message End If without block If

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Multiple if statements in a for loop

    Hi again,

    Ok on that, but in order to make a further suggestion I would need to see the entire routine rather than just the code snippet you posted.

    Regards,

    Greg M

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Multiple If statements with multiple then statements pulling from Index/Match commands
    By Reggie Wells in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-30-2017, 03:25 PM
  2. imbedded if statements in a for loop
    By Dlhans in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-10-2017, 07:52 PM
  3. Loop with two statements
    By elmnas in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-25-2016, 08:39 AM
  4. [SOLVED] For loop with mulitple if statements.
    By Petter120 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-03-2014, 02:31 PM
  5. Multiple If statements inside a for loop error
    By pvhs07 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2013, 01:00 PM
  6. Replies: 12
    Last Post: 05-15-2009, 08:38 AM
  7. VBA Do...Loop Statements
    By liseladele in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-24-2006, 06:57 AM

Tags for this Thread

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