我有一个需要Vba代码的excel工作表。我有A:M的数据输入列,必须由用户输入。 然后,Manager必须在N列中选择“ APPROVED”。必须对“ APPROVED”的选择进行密码保护,以便只有Manager才能使用它。管理员输入密码并选择“已批准”后,必须在O列中填充用户签名并锁定该行。
这对于工作表中的每一行都必须是可能的。
我发现了以下用于添加用户签名的代码,但是此代码会将用户签名添加到下一个空白行。这不能解决我的要求。
Sub SignSheet()
Dim RowNum As Integer
Dim PassWD As String
Dim SignatureWS As String
'this is the name of the worksheet with the signatures
SignatureWS = "SignedOff"
'this is the password used to protect/unprotect the worksheet
PassWD = "Password"
RowNum = 1
'this unprotects the worksheet with the password stored in the variable PassWD
Worksheets(SignatureWS).Unprotect Password:=PassWD
'this starts in row 1 and works its way down until an empty cell in colum A is found
'to put the new signature in
Do Until IsEmpty(Worksheets(SignatureWS).Range("A" & RowNum)) = True
RowNum = RowNum + 1
Loop
'this puts the window's username in column A at an empty cell
Worksheets(SignatureWS).Range("A" & RowNum).Value = Application.UserName
'this puts the date and time they "signed" the worksheet in column B
Worksheets(SignatureWS).Range("B" & RowNum).Value = Now
'this protects the worksheet with the password set in the PassWD variable
Worksheets(SignatureWS).Protect Password:=PassWD, DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
我也尝试过“用户保护范围”,但这也不能解决锁定每一行的要求。