简体   繁体   中英

Change value of a cell based on today`s date

I'm trying to change the value of a cell based on today's date and a date found in another column.

Column N captures the date an issue was opened and column H captures the status (open, closed, carried).

I'd like status to change to carried once the open date is no longer in the same month as today's date.

You need to add some more info in your post. However, as I only know two of your criteria's, this chunk of code should set column H to either Open or Closed based on the date given in column N.

Sub Capture()

Dim ws as worksheet
Dim fRow as Long
Dim curDate as Date

Set ws = ThisWorkbook.Worksheets(“YourSheet”)
curDate = Now()

with ws
  fRow = .Cells(.Rows.Count,13).end(xlUp).Row
End with

For i = 1 to fRow
With ws
    If .Cells(i, 13).Value > curDate Then
      .Cells(i, 8).Value = “Closed”
    Else
      .Cells(i, 8).Value = “Open”
  End if
End with
End sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM