How to trigger macro when combobox change

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • How to trigger macro when combobox change

    Hello,Can anyone help me in this issue, i have the below function to run whenever we open report:
    function __open(){
    $start = new DateTime(activeworkbook()->sheets('ChooseStep')->Range('J10')->value);
    $end = new DateTime(activeworkbook()->sheets('ChooseStep')->Range('J12')->value);
    // otherwise the end date is excluded
    $end->modify('+0 day');
    $interval = $end->diff($start);
    // total days
    $days = $interval->days;
    // create an iterateable period of date (P1D equates to 1 day)
    $period = new DatePeriod($start, new DateInterval('P1D'), $end);
    // best stored as array, so you can add more than one $holidays = array('2012-09-17');

    foreach($period as $dt) {$curr = $dt->format('D');
    // for the updated question
    if (in_array($dt->format('Y-m-d'), $holidays)) {$days--;}
    // substract if Saturday or Sunday
    if ($curr == 'Sat' $curr == 'Fri') {$days--;}}
    $target2 = activesheet()->range('H2');$target2->value=$days;}

    The above code basically calculating working days between date range.And the date range depends on the 2 combo box.

    Then I have below function that will call open() function whenever combobox has been selected:
    function _ComboBox3_Select (){return __open();}
    function _ComboBox4_Select (){return __open();}

    But then it doesn't gives me the real time calculation whenever I select dates from the combobox.Do we have event function in combobox?