Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.

...

Пример макроса

Блок кода
languagevb
collapselinenumberstrue
Function TestMonth() As Long
    Dim ws As Worksheet
    Dim lastRow As Long
    Dim currentMonthYear As String
    Dim cell As Range
    Dim counter As Long
    Set ws = ActiveSheet
    lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
    currentMonthYear = Format(Now, "MM.YY")
    counter = 0
    For Each cell In ws.Range("A1:A" & lastRow)
        Dim cellMonthYear As String
        cellMonthYear = Format(cell.Value, "MM.YY")
        If cellMonthYear <> currentMonthYear Then
            counter = counter + 1
            cell.Interior.Color = RGB(255, 0, 0)
        End If
    Next cell
    TestMonth = counter
End Function

...