I am trying to make a macro that adds a new checkbox when new data is inputed, but it should only be marked or unmarked when the sheet is unprotected. I tried to do this with the following code:
Range("Z4").Select
ActiveCell.FormulaR1C1 = "=LOOKUP(2,1/(C[-15]<>""""),ROW(C[-15]))"
i = Range("Z4").Value + 1
Cells(i, 19).Select
ActiveSheet.CheckBoxes.Add(Cells(i, 19).Left, Cells(i, 19).Top, 60.75, 15).Select
With Selection
.Value = xlOff
.LinkedCell = Cells(i, 30)
.Display3DShading = False
End With
Selection.Characters.Text = "Pagado"
Where the linked cell is locked and therefore should not be able to be changed when locked.
Otherwise, the rest of the code works perfectly.
Aucun commentaire:
Enregistrer un commentaire