Sanoj
Member
Hello,
I was trying to lock range of cell say A:HR if value of HR for that particular row is "Approved".
There are two sheets
1. View_Form - to view specific selected values and click macro button Approve.
2. Tracker - Data base where Cell HR updates while clicking Approval button of sheet 1
Wanted to lock range of cell A:HR if value of HR cell for that row is "Approved". sheet Tracker is password protected as "123". So the VBA should first unlock the sheet Tracker and after running the code should lock the cell back with password "123".
Any help??? this is the current code I am using for approval.
I was trying to lock range of cell say A:HR if value of HR for that particular row is "Approved".
There are two sheets
1. View_Form - to view specific selected values and click macro button Approve.
2. Tracker - Data base where Cell HR updates while clicking Approval button of sheet 1
Wanted to lock range of cell A:HR if value of HR cell for that row is "Approved". sheet Tracker is password protected as "123". So the VBA should first unlock the sheet Tracker and after running the code should lock the cell back with password "123".
Any help??? this is the current code I am using for approval.
Code:
Sub Approval()
Dim found As Range 'define variables
Dim SelectedFileID As String
ActiveSheet.Unprotect "123" '---------------Unprotect sheet
'Approval function
SelectedFileID = Sheets("View_Form").Range("SelFileID").Value 'get the currently selected File ID
Set found = Sheets("Tracker").Range("B:B").Find(What:=SelectedFileID) 'find the file ID in the Sheet Tracker
If Not found Is Nothing Then 'if found
Sheets("Tracker").Cells(found.Row, 226).Value = "Approved" 'change the value of the row it was found, but column 226 which is column HR
Else
MsgBox "ID not found in Sheet Tracker!", vbInformation 'if not found then show message
End If
ActiveSheet.Protect "123"
ActiveWorkbook.Save '---------------Save workbook
Application.DisplayAlerts = False
End Sub