+ Reply to Thread
Results 1 to 5 of 5

IF and ElseIf

  1. #1
    Registered User
    Join Date
    07-19-2013
    Location
    houston
    MS-Off Ver
    Excel 2010
    Posts
    56

    IF and ElseIf

    Hello, I am having some trouble with my if and elseif statements. I have data in potentially 4 sheets and if a cell is blank it goes on to the next, if not it runs code and then goes on to the next sheet. I am having trouble with sheets getting skipped. Below is a breakdown of what i have.The Then after a blank cell should move on to the next sheet.

    Sheets("Sheet 1").Select
    If Range ("A2") = "" Then
    Elseif Sheets("Sheet 1").Select Then
    'RUNS CODE"

    Sheets("Sheet 2").Select
    If Range ("A2") = "" Then
    Elseif Sheets("Sheet 2").Select Then
    'RUNS CODE'

    Sheets("Sheet 3").Select
    If Range ("A2") = "" Then
    Elseif Sheets("Sheet 3").Select Then
    'RUNS CODE'

    Sheets("Sheet 4").Select
    If Range ("A2") = "" Then
    Elseif Sheets("Sheet 4").Select Then
    'RUNS CODE'

    END IF
    END IF
    END IF
    END IF

  2. #2
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: IF and ElseIf

    Please Login or Register  to view this content.
    Is that what you mean? your question is not entirely clear

    Regards

    Dav

  3. #3
    Registered User
    Join Date
    07-19-2013
    Location
    houston
    MS-Off Ver
    Excel 2010
    Posts
    56

    Re: IF and ElseIf

    Sorry, what i mean is look at sheet 1, if blank go to sheet 2, if not run sheet 1 code and then go to sheet 2. if sheet 2 is blank go to sheet 3, if not run sheet 2 code and then go to sheet 3. etc etc.

  4. #4
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: IF and ElseIf

    I think the answer does that although

    Please Login or Register  to view this content.
    is maybe simpler, is that what you mean?

    regards

    Dav

  5. #5
    Registered User
    Join Date
    07-19-2013
    Location
    houston
    MS-Off Ver
    Excel 2010
    Posts
    56

    Re: IF and ElseIf

    AH I SEE. thanks that works

+ 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] When ElseIf condition is met, the statements under elseif are not happening.
    By excelkann in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-07-2016, 12:40 PM
  2. ElseIf Without If
    By HarryGreenwood in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2015, 05:12 AM
  3. If / ElseIf within For Each?
    By pwells in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-26-2014, 10:35 AM
  4. Code stepping in to elseif statement when elseif is definitely not true
    By DFrank231 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-13-2013, 05:31 PM
  5. If Elseif elseif problem
    By tjbillund in forum Excel General
    Replies: 3
    Last Post: 08-10-2011, 07:02 AM
  6. if elseif
    By flow23 in forum Excel General
    Replies: 0
    Last Post: 11-14-2005, 10:15 AM
  7. [SOLVED] Re: IF..Then..ELSE.. ELSEIF
    By rjamison in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-13-2005, 08:05 PM

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