Excel - Error de autimatizacion

 
Vista:
sin imagen de perfil

Error de autimatizacion

Publicado por Alejandro (1 intervención) el 07/12/2019 15:04:46
Buenos días, tengo un problema con el inicio de un formulario, me sale "error -2147220995(800401fd) en tiempo de ejecución." El cual me impide ejecutar el formulario, le doy depurar y me manda al modulo en cual veo todo bien, este error empezó después de active el control de microsoft outlook date y lo use en la edición del formulario.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
* Código del modulo.
 
 
Sub nomina()
    UserForm1.Show
 
End Sub
Sub vehiculos()
    UserForm2.Show
 
End Sub
Sub empleados()
    UserForm3.Show
 
End Sub
* Código del formulario.
 
Private Sub ComboBox1_Change()
Dim fila As Integer
Dim final As Integer
 
If (ComboBox1) = "" Then
 
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox6.Text = ""
 
    End If
 
For fila = 5 To 2000
    If Hoja3.Cells(fila, 2) = "" Then
    final = fila - 1
 
     Exit For
     End If
     Next
 
 
For fila = 5 To final
 
    If Val(ComboBox1.Value) = Hoja3.Cells(fila, 2) Then
            TextBox2.Text = Hoja3.Cells(fila, 3)
            TextBox3.Text = Hoja3.Cells(fila, 5)
            TextBox6.Text = Hoja3.Cells(fila, 4)
 
     Exit For
 
     Else
            TextBox2.Text = ""
            TextBox3.Text = ""
            TextBox6.Text = ""
 
     End If
     Next
 
 
End Sub
Private Sub CommandButton1_Click()
Dim fila As Integer
 
For fila = 9 To 2000
 
    If Hoja4.Cells(fila, 2) = "" Then
        Hoja4.Cells(fila, 2) = TextBox2.Text
        Hoja4.Cells(fila, 3) = TextBox3.Text
        Hoja4.Cells(fila, 4) = TextBox4.Text
        Hoja4.Cells(fila, 7) = TextBox7.Text
        Hoja4.Cells(fila, 9) = TextBox8.Text
        Hoja4.Cells(fila, 11) = TextBox9.Text
        Hoja4.Cells(fila, 13) = TextBox10.Text
        Hoja4.Cells(fila, 15) = TextBox11.Text
        Hoja4.Cells(fila, 17) = TextBox12.Text
        Hoja4.Cells(fila, 19) = TextBox13.Text
        Hoja4.Cells(fila, 24) = TextBox14.Text
        Hoja4.Cells(fila, 25) = TextBox15.Text
        Hoja4.Cells(fila, 26) = TextBox16.Text
 
      MsgBox "Realizado"
 
        ComboBox1 = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
        TextBox6.Text = ""
        TextBox7.Text = ""
        TextBox8.Text = ""
        TextBox9.Text = ""
        TextBox10.Text = ""
        TextBox11.Text = ""
        TextBox12.Text = ""
        TextBox13.Text = ""
        TextBox14.Text = ""
        TextBox15.Text = ""
        TextBox16.Text = ""
 
        ComboBox1.SetFocus
 
    Exit Sub
    End If
    Next
 
 
End Sub
Private Sub CommandButton2_Click()
 
        UserForm1.Hide
        ComboBox1.SetFocus
 
End Sub
Private Sub TextBox14_Change()
 
        TextBox14 = Format(TextBox14, "$ #,##0")
 
End Sub
Private Sub TextBox15_Change()
 
        TextBox15 = Format(TextBox15, "$ #,##0")
 
End Sub
Private Sub TextBox16_Change()
 
        TextBox16 = Format(TextBox16, "$ #,##0")
 
End Sub
Private Sub TextBox5_Change()
 
  If TextBox3 <= 2 * 828116 Then
            TextBox5 = 83000 / 30 * TextBox4
 
      Else
 
            TextBox5 = 0
 
     End If
 
            TextBox5 = Format(TextBox5, "$ #,##0")
 
End Sub
Espero me puedan ayudar, gracias por su atención.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Antoni Masana
Val: 4.908
Oro
Ha mantenido su posición en Excel (en relación al último mes)
Gráfica de Excel

Error de autimatizacion

Publicado por Antoni Masana (2463 intervenciones) el 09/12/2019 20:10:49
Deberías subir el libro para ver donde esta el error.

El código se ve bien y lo único que se ejecuta al llamar al formulario es la llamada al formulario, cuando se carga el formulario no se ejecuta ningún código de lo que has puesto. Son eventos que se ejecutan después de escribir o pulsar un botón.

El código así se lee un poco mejor.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
********** Código del modulo. ***************
 
Sub nomina()
    UserForm1.Show
End Sub
 
Sub vehiculos()
    UserForm2.Show
End Sub
 
Sub empleados()
    UserForm3.Show
End Sub
 
********** Código del formulario. **********
 
Private Sub ComboBox1_Change()
    Dim fila As Integer
    Dim final As Integer
    If (ComboBox1) = "" Then
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox6.Text = ""
    End If
    For fila = 5 To 2000
        If Hoja3.Cells(fila, 2) = "" Then
            final = fila - 1
            Exit For
        End If
    Next
    For fila = 5 To final
        If Val(ComboBox1.Value) = Hoja3.Cells(fila, 2) Then
            TextBox2.Text = Hoja3.Cells(fila, 3)
            TextBox3.Text = Hoja3.Cells(fila, 5)
            TextBox6.Text = Hoja3.Cells(fila, 4)
            Exit For
         Else
             TextBox2.Text = ""
             TextBox3.Text = ""
             TextBox6.Text = ""
         End If
     Next
End Sub
 
Private Sub CommandButton1_Click()
    Dim fila As Integer
    For fila = 9 To 2000
        If Hoja4.Cells(fila, 2) = "" Then
            Hoja4.Cells(fila, 2) = TextBox2.Text
            Hoja4.Cells(fila, 3) = TextBox3.Text
            Hoja4.Cells(fila, 4) = TextBox4.Text
            Hoja4.Cells(fila, 7) = TextBox7.Text
            Hoja4.Cells(fila, 9) = TextBox8.Text
            Hoja4.Cells(fila, 11) = TextBox9.Text
            Hoja4.Cells(fila, 13) = TextBox10.Text
            Hoja4.Cells(fila, 15) = TextBox11.Text
            Hoja4.Cells(fila, 17) = TextBox12.Text
            Hoja4.Cells(fila, 19) = TextBox13.Text
            Hoja4.Cells(fila, 24) = TextBox14.Text
            Hoja4.Cells(fila, 25) = TextBox15.Text
            Hoja4.Cells(fila, 26) = TextBox16.Text
            MsgBox "Realizado"
            ComboBox1 = ""
            TextBox2.Text = ""
            TextBox3.Text = ""
            TextBox4.Text = ""
            TextBox5.Text = ""
            TextBox6.Text = ""
            TextBox7.Text = ""
            TextBox8.Text = ""
            TextBox9.Text = ""
            TextBox10.Text = ""
            TextBox11.Text = ""
            TextBox12.Text = ""
            TextBox13.Text = ""
            TextBox14.Text = ""
            TextBox15.Text = ""
            TextBox16.Text = ""
            ComboBox1.SetFocus
            Exit Sub
        End If
    Next
End Sub
 
Private Sub CommandButton2_Click()
    UserForm1.Hide
    ComboBox1.SetFocus
End Sub
 
Private Sub TextBox14_Change()
    TextBox14 = Format(TextBox14, "$ #,##0")
End Sub
 
Private Sub TextBox15_Change()
    TextBox15 = Format(TextBox15, "$ #,##0")
End Sub
 
Private Sub TextBox16_Change()
    TextBox16 = Format(TextBox16, "$ #,##0")
End Sub
 
Private Sub TextBox5_Change()
    If TextBox3 <= 2 * 828116 Then
          TextBox5 = 83000 / 30 * TextBox4
      Else
          TextBox5 = 0
     End If
    TextBox5 = Format(TextBox5, "$ #,##0")
End Sub

Saludos.
\\//_
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar