EXCEL; changing cells after another cell is updated on protected worksheet -



EXCEL; changing cells after another cell is updated on protected worksheet -

edit: works if utilize activesheet.unprotect instead

ok if worksheet unprotected, next works fine!

private sub worksheet_change(byval target range) on error goto reset_enableevents application.enableevents = false if not intersect(target, range("d6:g6")) nil 'do next if d6 updated range("d7").interior.colorindex = 15 if range("d6") = "no" range("d7").interior.colorindex = 38 end if end if if not intersect(target, range("d7:g7")) nil 'do next if d6 updated if range("d7") <> "" range("d7").interior.colorindex = 15 end if end if if not intersect(target, range("e12:f12")) nil 'do next if e12:f12 updated range("d28").value = range("e12").value 'set d28 date entered in e12 range("c23").interior.colorindex = 36 ' reset color of cell c23 if range("e12") = "" ' next if e12 empty range("c39") = chr(34) & "do work period?" & chr(34) else range("c39") = chr(34) & "do work beyond " & range("e13").text & " (approx. period)?" & chr(34) if date >= range("e15").value range("c23").interior.colorindex = 3 end if end if end if if not intersect(target, range("e32")) nil 'do next if e32 updated if range("e32") = "yes" msgbox "please have client finish mva questionnaire." end if end if if not intersect(target, range("e41")) nil 'do next if e41 updated if range("e41") = "yes" range("d42").interior.colorindex = 38 elseif range("e41") = "no" range("d42").interior.colorindex = 36 range("d42") = "not required" elseif range("e41") = "" range("d42").interior.colorindex = 36 range("d42") = "" end if end if reset_enableevents: application.enableevents = true end sub

but when protect worksheet , allow unlocked cells selected, , add together password sheet, above cell background colors , cell values don't update

i tried adding activeworksheet.unprotect , protect @ origin , end , still wont work!

private sub worksheet_change(byval target range) on error goto reset_enableevents application.enableevents = false 'activeworksheet.unprotect password:="a" `..... if not intersect activeworksheet.protect password:="a" reset_enableevents: application.enableevents = true end sub

i tried putting protect , unprotect in each if statement , still didn't work,

if not intersect(target, range("e12:f12")) nil 'do next if e12:f12 updated activeworksheet.unprotect password:="a" range("d28").value = range("e12").value 'set d28 date entered in e12 range("c23").interior.colorindex = 36 ' reset color of cell c23 if range("e12") = "" ' next if e12 empty range("c39") = chr(34) & "do work period?" & chr(34) else range("c39") = chr(34) & "do work beyond " & range("e13").text & " (approx. period)?" & chr(34) if date >= range("e15").value range("c23").interior.colorindex = 3 end if end if activeworksheet.protect password:="a" end if

help??

i changed activesheet.protect , works

excel excel-vba

Comments

Popular posts from this blog

javascript - mongodb won't find my schema method in nested container -

Hibernate criteria by a list of natural ids -

ios - Lagging ScrollView with UIWebview inside -