Hi Everyone,
In my VBA code, I am looking to form a loop which can check the variables in Column A and for couple of variables in Column A unlock cell/cells from column D and For rest of the variables lock cell/cells from Column D & M.
Currently I have with error:
Private Sub Worksheet_Change()
Dim iRow As Long
Dim iLastRow As Long
iRow = 1
iLastRow = Bu1Calcsheet.cells(Rows.count, 1).End(xlUp).Row
Do While iRow<=iLastRow
If bu1CalcSheet.Cells(iRow, 1) Like "ABC" or bu1CalcSheet.Cells(iRow, 1) Like "XYZ" Then
bu1CalcSheet.Range("D" & iRow).Locked =False
bu1CalcSheet.Range("M" & iRow).Locked =False
ElseIf bu1CalcSheet.Cells(iRow, 1) Like "JKL" or bu1CalcSheet.Cells(iRow, 1) Like "DYU" or bu1CalcSheet.Cells(iRow, 1) Like "SPP" Then
bu1CalcSheet.Range("D" & iRow).Locked = True
End If
iRow=iRow+1
Loop
End Sub
Any idea?
In my VBA code, I am looking to form a loop which can check the variables in Column A and for couple of variables in Column A unlock cell/cells from column D and For rest of the variables lock cell/cells from Column D & M.
Currently I have with error:
Private Sub Worksheet_Change()
Dim iRow As Long
Dim iLastRow As Long
iRow = 1
iLastRow = Bu1Calcsheet.cells(Rows.count, 1).End(xlUp).Row
Do While iRow<=iLastRow
If bu1CalcSheet.Cells(iRow, 1) Like "ABC" or bu1CalcSheet.Cells(iRow, 1) Like "XYZ" Then
bu1CalcSheet.Range("D" & iRow).Locked =False
bu1CalcSheet.Range("M" & iRow).Locked =False
ElseIf bu1CalcSheet.Cells(iRow, 1) Like "JKL" or bu1CalcSheet.Cells(iRow, 1) Like "DYU" or bu1CalcSheet.Cells(iRow, 1) Like "SPP" Then
bu1CalcSheet.Range("D" & iRow).Locked = True
End If
iRow=iRow+1
Loop
End Sub
Any idea?