i wondering how can 1 use vba/macros lock excel cells selected/highlighted user.
the code im using right locking entire sheet.
sub macro4() ' ' macro4 macro ' ' worksheets("sheet1").activate activesheet.unprotect cells.select selection.locked = true activesheet.protect end sub
any ideas on im doing wrong?
thank time.
if want perform actions on selected cell(s) every time new selection occurs, should rely on code being triggered when happens:
private sub worksheet_selectionchange(byval target range) selection.locked = true end sub
this inside file code given sheet; is, if want consider sheet1
, file have write code is: microsoft excel objects/sheet1 (sheet1)
.
update after comment
sub button1_click() selection.locked = true end sub
this code locks cells selected when button1
clicked.
Comments
Post a Comment