Private Sub CommandButton1_Click()
If TextBox1.Text = "" Or TextBox2.Text = "" Then '登陆按钮
MsgBox "请输入帐号(或密码)"
ElseIf TextBox1.Text = "admin" And TextBox2.Text = "888" Then Sheets("首页").Select
ElseIf TextBox1.Text = "abc" And TextBox2.Text = "123" Then Sheets("成员首页").Select
Else
MsgBox "输入错误"
End If
End Sub
为什么我点击后没反映呢?

解决方案 »

  1.   

    Private Sub CommandButton1_Click()
    If TextBox1.Text = "" Or TextBox2.Text = "" Then '登陆按钮
    MsgBox "请输入帐号(或密码)"
    ElseIf TextBox1.Text = "admin" And TextBox2.Text = "888" Then Sheets("首页").Activate
    ElseIf TextBox1.Text = "abc" And TextBox2.Text = "123" Then Sheets("成员首页").Activate
    Else
    MsgBox "输入错误"
    End If
    End Sub
      

  2.   

    你 Sheets("首页").Select 有什么目的,或者说你要达到什么目的?
      

  3.   

    不要用这么多ELSEIF
    直接用多个IF语句反而更清楚
      

  4.   

    怎么没加sheets.Visible = False
      

  5.   

    是不是在窗体控件里面写的代码,试一下吧sheet改为 thisworkbook.worksheets
      

  6.   

    焦点问题
    sheet是引用excel里的表单