Triggering VBA code using Form Control Check Box instead of ActiveX -
i have code below working in budget template work. however, before roll out users, need make mac friendly. since macs don't activex controls, i'm trying figure out way make code work using form controls. have ideas me? thanks!
private sub travelcalc_click() activesheet.unprotect password:="password" if me.travelcalc.value = false range("c19:l20").locked = false sheets("travel calculator").visible = false else sheets("travel calculator").visible = true range("$c$19") = worksheets("travel calculator").range("$n$25") range("$d$19") = worksheets("travel calculator").range("$p$25") range("$e$19") = worksheets("travel calculator").range("$r$25") range("$f$19") = worksheets("travel calculator").range("$t$25") range("$g$19") = worksheets("travel calculator").range("$v$25") range("$h$19") = worksheets("travel calculator").range("$x$25") range("$i$19") = worksheets("travel calculator").range("$z$25") range("$j$19") = worksheets("travel calculator").range("$ab$25") range("$k$19") = worksheets("travel calculator").range("$ad$25") range("$l$19") = worksheets("travel calculator").range("$af$25") range("$c$20") = worksheets("travel calculator").range("$n$51") range("$d$20") = worksheets("travel calculator").range("$p$51") range("$e$20") = worksheets("travel calculator").range("$r$51") range("$f$20") = worksheets("travel calculator").range("$t$51") range("$g$20") = worksheets("travel calculator").range("$v$51") range("$h$20") = worksheets("travel calculator").range("$x$51") range("$i$20") = worksheets("travel calculator").range("$z$51") range("$j$20") = worksheets("travel calculator").range("$ab$51") range("$k$20") = worksheets("travel calculator").range("$ad$51") range("$l$20") = worksheets("travel calculator").range("$af$51") range("c19:l20").locked = true end if activesheet.protect password:="password", allowformattingcolumns:=true, allowformattingrows:=true end sub
after insert form control, right click it, , select assign macro, , select new. macro assigned "click event".
checking if has been checked bit tricky, doable:
private sub checkbox1_click() 'assign macro checkbox; make sure in standard module activesheet.unprotect password:="password" if activesheet.shapes("check box 1").oleformat.object.value <> 1 range("c19:l20").locked = false sheets("travel calculator").visible = false else yadda-yadda code here... end if activesheet.protect password:="password", allowformattingcolumns:=true, allowformattingrows:=true end sub
to honest, can hope works on mac, never tried that. if form controls work ok, should it...
Comments
Post a Comment