+ Reply to Thread
Results 1 to 14 of 14

Check Date to see if it has been Reached

Hybrid View

  1. #1
    Registered User
    Join Date
    08-19-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    77

    Check Date to see if it has been Reached

    Hello I have the following problem.

    I have dates listed in Column F. I need help creating a macro that will look through Column F and see which dates have passed or hsa been met based on the day the macro is run. If it finds a date that has passed or has been met then it will check Columns G and I and see if in that row those columns have any values. If either one of them do then the program will skip this date and go to the next date to check. If they are both empty then in the row with the current date being checked Column H receives a value of "Yes". Thanks for any help I can get on this.

  2. #2
    Registered User
    Join Date
    08-28-2014
    Location
    São Paulo
    MS-Off Ver
    2007
    Posts
    30

    Re: Check Date to see if it has been Reached

    So, as long as you name cell C8 with the =TODAY() function it should work. Does that help you or you need a function imputed inside the macro?

    Sub dateval()
    Dim lin As Integer
    Dim valor As Double

    lin = 1
    valor = Cells(lin, 6)
    While Cells(lin + 1, 6) <> Empty
    lin = lin + 1
    valor = Cells(lin, 6)
    If valor = Cells(8, 3) Or valor > Cells(8, 3) Then
    Cells(lin, 7) = "ok"
    End If
    Wend
    End Sub

  3. #3
    Registered User
    Join Date
    08-28-2014
    Location
    São Paulo
    MS-Off Ver
    2007
    Posts
    30

    Re: Check Date to see if it has been Reached

    Hey, it's better this way (I suppose)

    Sub dateval()
    Dim lin As Integer
    Dim valor As Double

    lin = 1
    valor = Cells(lin, 6)
    While Cells(lin + 1, 6) <> Empty
    lin = lin + 1
    valor = Cells(lin, 6)
    If valor = date Or valor > date Then
    Cells(lin, 7) = "ok"
    End If
    Wend
    End Sub


    Cheers

  4. #4
    Registered User
    Join Date
    08-19-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    77

    Re: Check Date to see if it has been Reached

    It works I just forgot to include one thing that is making it not work correctly for me. In column F there will be spaces in between some of the rows. So i would need it to run for the whole column say up to 5000 rows.

  5. #5
    Registered User
    Join Date
    08-19-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    77

    Re: Check Date to see if it has been Reached

    Actually hold on let me do some more tests.

  6. #6
    Registered User
    Join Date
    08-19-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    77

    Re: Check Date to see if it has been Reached

    Besides for that one thing from the last post. I'm noticing that its not noticing the right columns. If the date criteria is met then its suppose to check Columns G and I to see if they have any values in them. If either one of those columns do. Then Column H wont receive anything. If both columns G and I are empty after the date criteria is met then Column H will receive a "yes".

  7. #7
    Registered User
    Join Date
    08-19-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    77

    Re: Check Date to see if it has been Reached

    Ok I have the following code that works for the task I needed.
    Sub colorcheck3()
    
    
        Dim sOne As Worksheet
        Dim sTwo As Worksheet
        
        Set sOne = ThisWorkbook.Sheets("Sheet1") ' CHANGE ME
        Set sTwo = ThisWorkbook.Sheets("Sheet2") ' CHANGE ME
        
        Dim startRow1 As Integer
        Dim endRow1 As Long
            
        startRow1 = 1
        endRow1 = sOne.Cells(Rows.Count, "C").End(xlUp).Row
        
        Dim startRow2 As Integer
        Dim endRow2 As Long
            
        startRow2 = 12
        
        endRow2 = sTwo.Cells(Rows.Count, "A").End(xlUp).Row
        For x = startRow1 To endRow1
            If sOne.Cells(x, 3).Interior.ColorIndex <> -4142 Then
                For y = startRow2 To endRow2 Step 1
                    If sOne.Cells(x, 3).Value = sTwo.Cells(y, 1) Then
                        If sTwo.Cells(y, 9).Value <> "Yes" Then
                           If Format(sTwo.Cells(y, 6).Value, "m/d/yyyy") >= Format(Now(), "m/d/yyyy") Then
                                        sTwo.Cells(y, 8) = ""
                                    Else
                                        If sTwo.Cells(y, 7).Value <> "Yes" Then
                                            sTwo.Cells(y, 8) = "Yes"
                                        End If
                                End If
                            End If
                        End If
                Next y
            End If
        Next x
        
    End Sub
    The problem i'm running into is that in cell(y,6) I have the following formula that is pulling the date:
    =IF(ISNUMBER(E14),WORKDAY(E14,2,$N$1:$P$2),"")
    How can I change the code or add to it that will read the cell correctly because right now it isn't reading it as a date.

  8. #8
    Registered User
    Join Date
    08-28-2014
    Location
    São Paulo
    MS-Off Ver
    2007
    Posts
    30

    Re: Check Date to see if it has been Reached

    How many blank spaces between dates would you have? I think it's a easier way to do it

  9. #9
    Registered User
    Join Date
    08-19-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    77

    Re: Check Date to see if it has been Reached

    It could vary no set number.

  10. #10
    Registered User
    Join Date
    08-28-2014
    Location
    São Paulo
    MS-Off Ver
    2007
    Posts
    30

    Re: Check Date to see if it has been Reached

    Are you using excel 2007?

  11. #11
    Registered User
    Join Date
    08-19-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    77

    Re: Check Date to see if it has been Reached

    No I'm using Excel 2013.

  12. #12
    Registered User
    Join Date
    08-28-2014
    Location
    São Paulo
    MS-Off Ver
    2007
    Posts
    30

    Re: Check Date to see if it has been Reached

    Could you try this?

    Sub dateval()
    Dim lin As Integer
    Dim lin2 As Long
    Dim value As Double
    
    lin = 1
    lin2 = 999999
    value = Cells(lin, 6)
    
    While Cells(lin2, 6) = Empty
    
        lin2 = lin2 - 1
    
    Wend
    
    While lin <> lin2
        lin = lin + 1
        value = Cells(lin, 6)
        If value = Date Or value > Date Then
            Cells(lin, 7) = "ok"
        End If
        
    Wend
        
    End Sub

  13. #13
    Registered User
    Join Date
    08-19-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    77

    Re: Check Date to see if it has been Reached

    I'm getting an error and that could be because in Column F it is not a normal Date value. Listed above I showed the formula that I have in there to pull a certain date for me. So with the code that I have thats working mostly I'm just trying to figure out how to make it read that cell correctly instead of looking for a date value.

  14. #14
    Registered User
    Join Date
    08-28-2014
    Location
    São Paulo
    MS-Off Ver
    2007
    Posts
    30

    Re: Check Date to see if it has been Reached

    You need the formula to be in date format, right?
    Does that help?

    =DATE(YEAR(IF(ISNUMBER(E14),WORKDAY(E14,2,$N$1:$P$2),""));MONTH(IF(ISNUMBER(E14),WORKDAY(E14,2,$N$1:$P$2),""));DAY(IF(ISNUMBER(E14),WORKDAY(E14,2,$N$1:$P$2),"")))

+ 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. Return date at which a sum was reached
    By mihigh07 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 08-20-2020, 03:59 AM
  2. sending an email from excel when date is reached in a cell date
    By ldelafosse in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-28-2014, 08:58 PM
  3. Show the date when a sum is reached
    By jmm42278 in forum Excel General
    Replies: 1
    Last Post: 02-11-2014, 08:43 AM
  4. Replies: 1
    Last Post: 04-18-2012, 05:49 PM
  5. Replies: 2
    Last Post: 09-09-2011, 12:30 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