+ Reply to Thread
Results 1 to 6 of 6

IF, And, Then with two Criteria

Hybrid View

  1. #1
    Registered User
    Join Date
    11-09-2015
    Location
    Florida
    MS-Off Ver
    O365
    Posts
    61

    IF, And, Then with two Criteria

    Hoping you all can give me a nudge in the right direction. I'm trying to do the below if/then with an AND and it's not working. I'm guessing I'm missing a reference for the bit after the AND, but not sure of the syntax.

    Will add attachment, but essential this and code is below. Looking for a text to return in the Status Column.

    Charter_Status Signature Status
    Renewal Not Started No
    Renewal Not Started No
    On Hold No
    In Progress Yes
    On Hold No
    In Progress No
    Renewal Not Started No
    Renewal Not Started No
    In Progress Yes
    On Hold No



    Sub Macro2()
    '
    ' Macro2 Macro
    '
    For Each Charter_Status In Range("A2:A11")
        If Charter_Status = "Renewal Not Started" Then
        Charter_Status.Offset(0, 2).Value = "Not Started"
        
        ElseIf Charter_Status = "In Progress" And Signature = "Yes" Then
        Charter_Status.Offset(0, 2).Value = "Waiting for FOR Signature"
        
        ElseIf Charter_Status = "In Progress" And Waiting_FOR_Signature = "No" Then
        Charter_Status.Offset(0, 2).Value = "In Progress"
        
        ElseIf Charter_Status = "On Hold" Then
        Charter_Status.Offset(0, 2).Value = "Hold"
    
        End If
        
    Next Charter_Status
        
    '
    End Sub
    Attached Files Attached Files
    Last edited by willhh3; 12-01-2021 at 02:29 PM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: IF, And, Then with two Criteria

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code] [/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Registered User
    Join Date
    11-09-2015
    Location
    Florida
    MS-Off Ver
    O365
    Posts
    61

    Re: IF, And, Then with two Criteria

    Done! Sorry about that; I've never posted code before, usually just questions.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: IF, And, Then with two Criteria

    Thanks!

    Open for all VBA helpers (not me... totally infantile with VBA).

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: IF, And, Then with two Criteria

    My first post in two years' time. Almost forgotten to code.

    Option Explicit

    Sub Macro2()
    '
    ' Macro2 Macro
    '
    Dim Charter_Status As Range
    For Each Charter_Status In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
        If Charter_Status = "Renewal Not Started" Then
            Charter_Status.Offset(0, 2).Value = "Not Started"
        
        ElseIf Charter_Status = "In Progress" And Charter_Status.Offset(0, 1).Value = "Yes" Then
            Charter_Status.Offset(0, 2).Value = "Waiting for for Signature"
            
        ElseIf Charter_Status = "In Progress" And Charter_Status.Offset(0, 1).Value = "No" Then
            Charter_Status.Offset(0, 2).Value = "In Progress"
    
        
        ElseIf Charter_Status = "On Hold" Then
            Charter_Status.Offset(0, 2).Value = "Hold"
    
        End If
        
    Next Charter_Status
        
    '
    End Sub
    Last edited by AB33; 12-01-2021 at 03:28 PM.

  6. #6
    Registered User
    Join Date
    11-09-2015
    Location
    Florida
    MS-Off Ver
    O365
    Posts
    61

    Re: IF, And, Then with two Criteria

    Thanks AB33! I see that I needed the Offset on the second value. Tested it in my sample and my full data worksheet. Works like a champ! Thanks for the guidance and quick turn-around!

+ 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. Replies: 1
    Last Post: 04-09-2021, 11:09 AM
  2. Replies: 2
    Last Post: 12-27-2020, 04:10 AM
  3. [SOLVED] Usine sumifs to change criteria range column based on dynamic criteria
    By Luiscarlos in forum Excel General
    Replies: 5
    Last Post: 11-19-2020, 09:33 AM
  4. Replies: 1
    Last Post: 03-25-2020, 08:06 AM
  5. Replies: 2
    Last Post: 01-03-2017, 08:40 AM
  6. Replies: 4
    Last Post: 11-01-2016, 03:28 PM
  7. Replies: 4
    Last Post: 01-08-2013, 12:37 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