Lock rows in Excel using VBA -


i have excel sheet columns f filled out different users. once 1 row completed user (control user) enteres "done" in column g. user entered "done" in coulmn g, want vba script lock entire row (column g) no 1 can change of row entries longer. possible using vba scripting?

we must start cells un-protected , sheet locked

enter following event macro in worksheet code area:

private sub worksheet_change(byval target range)     dim n long     n = target.row     if intersect(target, range("g:g")) nothing exit sub     if target.text <> "done" exit sub     activesheet.unprotect       range("a" & n & ":g" & n).locked = true     activesheet.protect end sub 

because worksheet code, easy install , automatic use:

  1. right-click tab name near bottom of excel window
  2. select view code - brings vbe window
  3. paste stuff in , close vbe window

if have concerns, first try on trial worksheet.

if save workbook, macro saved it. if using version of excel later 2003, must save file .xlsm rather .xlsx

to remove macro:

  1. bring vbe windows above
  2. clear code out
  3. close vbe window

to learn more macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

and

http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx

to learn more event macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

macros must enabled work!


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -