安排代码,停留在如何在用户窗体内的组合框中执行操作

时间:2019-07-10 18:38:25

标签: excel userform

我需要一些帮助来安排我的科学怪人代码,我是一个尝试学习的菜鸟,最好的学习方法是了解命令和练习。因此,让我们描述一下我的问题...

我向我的公司提供了一种使我们的服务台生活更轻松的方法,因为该公司没有提供对我们有用的东西...而且我有一个绝妙的主意,将VBA用于excel cos,我知道一些东西。在此基础上,我制作了一个用户表单,并携带了我们需要的所有信息,但是我需要帮助来完成这些步骤。

1)使其起作用,按一个按钮以打开并执行表单(完成) 2)使表格使用框搜索并带来值(完成) 3)制作一个组合框,如果选择了一个值(具有4个值),系统将执行一项操作。 (需要帮助才能完成) 4)携带搜索找到的所有值(完成) 5)清除先前的搜索,然后重置表格以开始(需要帮助来创建)。 6)在搜索中带一个文件或一个包含.PDF ou之类的文件的文件夹    .DOC(不知道如何制作或在文件夹中放置一个超链接    位置)

现在,我将放置代码,并希望一位好心人能帮助我和我的同事。

    Private Sub ComboBox1_Change()
    If ComboBox1.Value = "CÓDIGO" Then
        With Sheet1.Range("A:H")
              Set C = .Find(Pesquisa_Box.Value, LookIn:=xlValues, LOOKAT:=xlWhole)
              If Not C Is Nothing Then

                   Codigo_box.Text = C.Offset(0, 0)
                   Resolutiva_box.Text = C.Offset(0, 1)
                   Atuacao_Box.Text = C.Offset(0, 2)
                   Status_box.Text = C.Offset(0, 3)
                   BUG_Box.Text = C.Offset(0, 7)
                   TASK_Box.Text = C.Offset(0, 4)
                   WA_Box.Text = C.Offset(0, 5)
                   PB_Box.Text = C.Offset(0, 6)
                   BuscaG_BOX.Text = C.Offset(0, 8)
                   IOP_Box.Text = C.Offset(0, 10)

              End If
              If C Is Nothing Then
              MsgBox ("Nome Não Encontrado!!!"), vbOKOnly, ("Seu Aplicativo Pesquisando Dados")
              End If
              End With

    If ComboBox1.Value = "WA" Then
        With Sheet1.Range("A:H")
              Set C = .Find(Pesquisa_Box.Value, LookIn:=xlValues, LOOKAT:=xlWhole)
              If Not C Is Nothing Then

                      'WA
                      Codigo_box.Text = C.Offset(0, 0)
                      Resolutiva_box.Text = C.Offset(0, 1)
                      Atuacao_Box.Text = C.Offset(0, 2)
                      Status_box.Text = C.Offset(0, 3)
                      BUG_Box.Text = C.Offset(0, 7)
                      TASK_Box.Text = C.Offset(0, 4)
                      WA_Box.Text = C.Offset(0, 5)
                      PB_Box.Text = C.Offset(0, 6)
                      BuscaG_BOX.Text = C.Offset(0, 8)
                      IOP_Box.Text = C.Offset(0, 10)

              End If
              If C Is Nothing Then
              MsgBox ("Nome Não Encontrado!!!"), vbOKOnly, ("Seu Aplicativo Pesquisando Dados")
              End If
              End With

    If ComboBox1.Value = "TASK" Then
        With Sheet1.Range("A:H")
              Set C = .Find(Pesquisa_Box.Value, LookIn:=xlValues, LOOKAT:=xlWhole)
              If Not C Is Nothing Then

                      'TASK
                      Codigo_box.Text = C.Offset(0, 0)
                      Resolutiva_box.Text = C.Offset(0, 1)
                      Atuacao_Box.Text = C.Offset(0, 2)
                      Status_box.Text = C.Offset(0, 3)
                      BUG_Box.Text = C.Offset(0, 7)
                      TASK_Box.Text = C.Offset(0, 4)
                      WA_Box.Text = C.Offset(0, 5)
                      PB_Box.Text = C.Offset(0, 6)
                      BuscaG_BOX.Text = C.Offset(0, 8)
                      IOP_Box.Text = C.Offset(0, 10)

              End If
              If C Is Nothing Then
              MsgBox ("Nome Não Encontrado!!!"), vbOKOnly, ("Seu Aplicativo Pesquisando Dados")
              End If
              End With

    If ComboBox1.Value = "Busca Genérica" Then
        With Sheet1.Range("A:H")
              Set C = .Find(Pesquisa_Box.Value, LookIn:=xlValues, LOOKAT:=xlWhole)
              If Not C Is Nothing Then

                      'Busca Genérica
                      Codigo_box.Text = C.Offset(0, 0)
                      Resolutiva_box.Text = C.Offset(0, 1)
                      Atuacao_Box.Text = C.Offset(0, 2)
                      Status_box.Text = C.Offset(0, 3)
                      BUG_Box.Text = C.Offset(0, 7)
                      TASK_Box.Text = C.Offset(0, 4)
                      WA_Box.Text = C.Offset(0, 5)
                      PB_Box.Text = C.Offset(0, 6)
                      BuscaG_BOX.Text = C.Offset(0, 8)
                      IOP_Box.Text = C.Offset(0, 10)


              End If
              If C Is Nothing Then
              MsgBox ("Nome Não Encontrado!!!"), vbOKOnly, ("Seu Aplicativo Pesquisando Dados")
              End If
              End With
        End If
        End If
        End If
        End If
        End Sub

------------------------------------------------------------------------------

    Private Sub LimparDados_Click()
    Dim ctl As Control
    For Each ctl In Me.Controls
    If TypeName(ctl) = "TextBox" Then
    ctl.Text = vbNullString
    End If
    Next ctl 
   End Sub
-----------------------------------------------------------------------------

    Private Sub UserForm_Initialize()
    Dim Linha As Integer
  Linha = 1
    Do Until Sheet1.Cells(Linha, 17) = “”
    ComboBox1.AddItem Sheet1.Cells(Linha, 17)
  Linha = Linha + 1
    Loop
         End Sub

------------------------------------------------------------------------------

    Private Sub Pesquisar_Bot_Click()
    With Sheet1.Range("A:H")
    Set C = .Find(Pesquisa_Box.Value, LookIn:=xlValues, LOOKAT:=xlWhole)
    If Not C Is Nothing Then

    'CÓDIGO
      Codigo_box.Text = C.Offset(0, 0)
      Resolutiva_box.Text = C.Offset(0, 1)
      Atuacao_Box.Text = C.Offset(0, 2)
      Status_box.Text = C.Offset(0, 3)
      BUG_Box.Text = C.Offset(0, 7)
      TASK_Box.Text = C.Offset(0, 4)
      WA_Box.Text = C.Offset(0, 5)
      PB_Box.Text = C.Offset(0, 6)
      BuscaG_BOX.Text = C.Offset(0, 8)
      IOP_Box.Text = C.Offset(0, 10)


     End If
     If C Is Nothing Then
     MsgBox ("Nome Não Encontrado!!!"), vbOKOnly, ("Seu Aplicativo Pesquisando Dados")
     End If
     End With
     End Sub

This is my user form and some of my columns

0 个答案:

没有答案