我的数据包含包含Month的单元格A1 .
A2:Z999:员工详细信息 . P栏:加入日期 .
我想编写代码,当P> A1时,它应该锁定该员工的行,因为它是旧数据 . 只有没有日期的行或空行999才能为空 .
请帮忙!现在我的代码锁定了一切 .
Dim DestSh As Worksheet
Dim lastrow As Long
Set DestSh = Sheets("Consultant & Teacher")
With DestSh
If Application.WorksheetFunction.CountA(.Cells) <> 0 Then
lastrow = .Columns("A:z").Find(What:="*", _
After:=.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
Else
MsgBox "Insufficient rows"
End If
If Range("A1").Value = "April" Then
.Unprotect Password:="MyPassword"
.Cells.Locked = False
.Range("A2:Z" & lastrow).Locked = True
1 回答
我不太确定你用现有代码想要完成什么,但纯粹基于你解释的内容,我认为这应该可以解决问题: