Userform初始化

时间:2015-08-10 12:25:49

标签: excel vba excel-vba userform

在我的Userform Initialisation中,我默认将optionbutton1和optionbutton4的值设置为true。有四个选项按钮。如果用户单击任何其他选项按钮,我希望以下是图表标题。

我已经调用了与命令按钮相关的子过程:

Sub ChartName()
    If UserForm1.OptionButton1.value = True And UserForm1.OptionButton3.value = True Then
        ActiveChart.ChartTitle.Text = "First Case"
    ElseIf UserForm1.OptionButton2.value = True And UserForm1.OptionButton3.value = True Then
        ActiveChart.ChartTitle.Text = "Second Case"
    ElseIf UserForm1.OptionButton1.value = True And UserForm1.OptionButton4.value = True Then
        ActiveChart.ChartTitle.Text = "Third Case"
    ElseIf UserForm1.OptionButton2.value = True And UserForm1.OptionButton4.value = True Then
        ActiveChart.ChartTitle.Text = "Fourth Case"
End Sub

但是,无论用户选择什么,默认的optionbutton1和optionbutton3都被视为true,因此始终显示“First Case”。

有人可以向我建议如何解决这个问题吗?

1 个答案:

答案 0 :(得分:-1)

我不太了解你的情况,我希望如此。试试这个:

<script>
   function isIE () {
       var myNav = navigator.userAgent.toLowerCase();
       return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false;
   }    
   var ua = window.navigator.userAgent;
   //Internet Explorer | if | 9-11

   if (isIE () == 9) {
       alert("Shut down this junk! | IE 9");
   } else if (isIE () == 10){
       alert("Shut down this junk! | IE 10");
   } else if (ua.indexOf("Trident/7.0") > 0) {
       alert("Shut down this junk! | IE 11");
   }else{
       alert("Thank god it's not IE!");
   }

</script>
相关问题