excel - CommandButton Clicking vs Executing from VBA Editor,[Updated] -
updated===========================================================
so debugging night through.. , still can't figure out going wrong..
if have @ these 2 captured images...
basically, stepping next line should not change selected tab shown here. happens if click f5 vba editor execute sub
but when run using linked command button suppose doing same thing (photo shown down thread). happens this,
stepping next line somehow changes tab!
there noting in first break point line tells excel select tab... why doing this.
if run using f8, problems goes away.
updated=============================================================
i come across weird behaviour in excel vba , can't explain why doing it.
sub run_simulation() activeworkbook.worksheets("run simulation").select activesheet.commandbutton1.value = true end sub
this subroutine selects sheets simulates clicking of button 'commandbutton1'.
when execute play icon within vba editor runs fine when run 'run_simulation' subroutine linked button on sheet...
an error returns saying selected sheet "run_simulation" protected , needs unprotected before proceeding... thing unprotects sheets automatically when commandbutton1 clicked.
the worksheet.protect method has little-used userinterfaceonly parameter.
from msdn:
userinterfaceonly (optional) - true protect user interface, not macros. if argument omitted, protection applies both macros , user interface.
set true when setting worksheet protection , able manipulate worksheet objects programmatically.
Comments
Post a Comment