+ Reply to Thread
Results 1 to 5 of 5

If...Then Statement Down a Column

  1. #1
    Registered User
    Join Date
    06-17-2013
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    37

    If...Then Statement Down a Column

    Hi,

    I have an IF then statement for my starting cell for a particular column. How do I extend the formula down to the end of the column of used rows? Nothing I have tried has worked so far. Basically I am comparing two dates and inserting the results into a third column. Here is the code below. I cannot figure out how to extend it. Thanks for your help!

    Sub Testing()
    Dim A5 As Date
    Dim B5 As Date
    Dim C5 As Date
    If Range("A5") > Range("B5") Or Range("B5") Is Nothing Then
    Range("C5") = "OnTime"
    Else: Range("C5") = "Late"

    End If
    End Sub

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

    Re: If...Then Statement Down a Column

    Please use code tags with your code. This code loops from row 5 to last row in column A and rest is your code.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-17-2013
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: If...Then Statement Down a Column

    Sorry about the code tags, I will include them next time. Thank you so much for your help. The code works for the most part, except excel seems to be confused by the blank cells. I want excel to recognize the blank cells as Late, not On Time. Right now it shows blanks as on time. Do you have any idea how to do that? Thanks so much!

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

    Re: If...Then Statement Down a Column

    I am not sure, but try one of these codes and if none work, we will twist the ifs stat.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-17-2013
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: If...Then Statement Down a Column

    I got it to work! I used your original code and just flipped the < sign. Thank you so much for your help!

+ 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