A
A.S.
Using Min function, I was able to find the next (soonest) date, but not able
to color the cell. I used MsgBox to see if any address was assigned to
rngFound. Then used rngFound.Cells.Activate to see where the cell was, which
resulted way below the list. What did I do wrong? Here is the code:
Sub FindNext()
Dim myRange As Range
Dim answer As String
Dim rngFound As Range
Set myRange = Worksheets("Sheet5").Range("K2:K80")
answer = Application.WorksheetFunction.Min(myRange)
Set rngFound = myRange(answer)
MsgBox rngFound.Address
answer = Format(answer, "mm/dd/yy")
MsgBox ("The next date is " & answer)
rngFound.Cells.Activate
rngFound.Font.ColorIndex = 3
End Sub
to color the cell. I used MsgBox to see if any address was assigned to
rngFound. Then used rngFound.Cells.Activate to see where the cell was, which
resulted way below the list. What did I do wrong? Here is the code:
Sub FindNext()
Dim myRange As Range
Dim answer As String
Dim rngFound As Range
Set myRange = Worksheets("Sheet5").Range("K2:K80")
answer = Application.WorksheetFunction.Min(myRange)
Set rngFound = myRange(answer)
MsgBox rngFound.Address
answer = Format(answer, "mm/dd/yy")
MsgBox ("The next date is " & answer)
rngFound.Cells.Activate
rngFound.Font.ColorIndex = 3
End Sub