我在小区A1中提到过日期,前 - “五月” .
我现在正试图用列Z锁定2-last行,其中提到每个员工的加入日期并将其与A1进行比较 .
如果这个单元格Z的月份> A1,那么我试图锁定该行 . 不知道该怎么办 .
下面的代码没有帮助:
Sub Lockrow()
Dim DestSh As Worksheet
Dim lastrow As Long
Dim i As Integer
Set DestSh = Sheets("Consultant & Teacher")
With DestSh
'finds the last row with data on A column
lastrow = Range("A65536").End(xlUp).Row
'parse all rows
For i = 6 To lastrow
'if your conditions are met
If Month(.Cells(i, 26)) > Month(.Cells(1, 2)) Then
.Range("A" & i).EntireRow.Cells.Locked = True 'lock the row
End If
Next i
End With
End Sub
1 回答
这是你在尝试什么?