Eliminar error en tiempo de ejecución 13
Estoy trabajando con macros en excel 2010 y tengo un userform para el cual utilizo el código abajo descrito, todos los textbox me los llena bien pero al momento de aceptar y enviar los datos a las celdas respectivas me manda el error "error en tiempo de ejecución 13" y detiene la macro, pasa bien los datos pero ya no me deja trabajar, espero me puedan ayudar... Gracias
Private Sub Aceptar_Click()
Dim fila1 As Long
Dim ws As Worksheet
Set ws = Worksheets(2)
Range("B2").Select
'encontrar sig. Fila vacia
If Sheets("Egr").Range("B3") = "" Then
fila1 = ws.Cells(Rows.Count, 9).End(xlUp).Offset(0, 0).Row
Else
fila1 = ws.Cells(Rows.Count, 9).End(xlUp).Offset(1, 0).Row
End If
'Desproteger Hoja Activa
ActiveSheet.Unprotect "2704"
'pasar datos a bdclientes
ws.Cells(fila1, 2).Value = Me.TextBox1.Value
ws.Cells(fila1, 3).Value = Me.TextBox2.Value
ws.Cells(fila1, 4).Value = Me.ComboBox1.Value
ws.Cells(fila1, 5).Value = Me.ComboBox2.Value
ws.Cells(fila1, 6).Value = Me.TextBox6.Value
ws.Cells(fila1, 7).Value = Me.TextBox7.Value
ws.Cells(fila1, 8).Value = Me.TextBox19.Value
ws.Cells(fila1, 9).Value = Me.TextBox8.Value
ws.Cells(fila1, 10).Value = Me.TextBox10.Value
ws.Cells(fila1, 11).Value = Me.TextBox11.Value
ws.Cells(fila1, 12).Value = Me.TextBox12.Value
ws.Cells(fila1, 13).Value = Me.TextBox13.Value
ws.Cells(fila1, 14).Value = Me.TextBox14.Value
ws.Cells(fila1, 15).Value = Me.ComboBox3.Value
ws.Cells(fila1, 16).Value = Me.TextBox17.Value
ws.Cells(fila1, 17).Value = Me.ComboBox4.Value
'Proteger Hoja Activa
ActiveSheet.Protect "2704", DrawingObjects:=True, Contents:=True, Scenarios:= _
True, AllowFiltering:=True
'limpiar formulario
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.ComboBox1.Value = ""
Me.ComboBox2.Value = ""
Me.TextBox6.Value = ""
Me.TextBox7.Value = ""
Me.TextBox8.Value = ""
Me.TextBox9.Value = ""
Me.TextBox19.Value = ""
Me.TextBox10.Value = ""
Me.TextBox11.Value = ""
Me.TextBox12.Value = ""
Me.TextBox13.Value = ""
Me.TextBox14.Value = ""
Me.ComboBox3.Value = ""
Me.TextBox17.Value = ""
Me.ComboBox4.Value = ""
Me.TextBox1.SetFocus
End Sub
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
On Error Resume Next
TextBox2.Text = Format(CDate(TextBox2), "dd/mm/yy")
If Err <> 0 Then
MsgBox ("Debe ingresar los valores con formato dd/mm/aa"), vbRetryCancel, ATENCION
Cancel = True
End If
End Sub
Private Sub TextBox7_AfterUpdate()
TextBox7 = FormatNumber(CDbl(TextBox7.Value), 2)
End Sub
Private Sub TextBox10_AfterUpdate()
TextBox10 = FormatNumber(CDbl(TextBox10.Value), 2)
End Sub
Private Sub TextBox11_AfterUpdate()
TextBox11 = FormatNumber(CDbl(TextBox11.Value), 2)
End Sub
Private Sub TextBox12_AfterUpdate()
TextBox12 = FormatNumber(CDbl(TextBox12.Value), 2)
End Sub
Private Sub TextBox13_AfterUpdate()
TextBox13 = FormatNumber(CDbl(TextBox13.Value), 2)
End Sub
Private Sub ComboBox1_Enter()
ComboBox1.RowSource = "TbProveedores"
End Sub
Private Sub ComboBox2_Enter()
ComboBox2.RowSource = "TbComprasGastos"
End Sub
Private Sub ComboBox3_Enter()
ComboBox3.RowSource = "Tabla3"
End Sub
Private Sub ComboBox4_Enter()
ComboBox4.RowSource = "Tabla5"
End Sub
Private Sub TextBox7_Change()
TextBox8.Text = Format((TextBox7.Text) * Val(TextBox19) / 100, "#,##0.00")
TextBox9.Text = Format(Val(TextBox7 * 1) + (TextBox8), "#,##0.00")
End Sub
Private Sub TextBox19_Change()
TextBox8.Text = Format((TextBox7.Text) * Val(TextBox19) / 100, "#,##0.00")
TextBox9.Text = Format(Val(TextBox7 * 1) + (TextBox8), "#,##0.00")
End Sub
Private Sub TextBox9_Change()
TextBox14 = Format((TextBox9) - Val(TextBox10) - Val(TextBox11) - Val(TextBox12) + Val(TextBox13), "#,##0.00")
End Sub
Private Sub TextBox10_Change()
TextBox14 = Format((TextBox9) - Val(TextBox10) - Val(TextBox11) - Val(TextBox12) + Val(TextBox13), "#,##0.00")
End Sub
Private Sub TextBox11_Change()
TextBox14 = Format((TextBox9) - Val(TextBox10) - Val(TextBox11) - Val(TextBox12) + Val(TextBox13), "#,##0.00")
End Sub
Private Sub TextBox12_Change()
TextBox14 = Format((TextBox9) - Val(TextBox10) - Val(TextBox11) - Val(TextBox12) + Val(TextBox13), "#,##0.00")
End Sub
Private Sub TextBox13_Change()
TextBox14 = Format((TextBox9) - Val(TextBox10) - Val(TextBox11) - Val(TextBox12) + Val(TextBox13), "#,##0.00")
End Sub
Private Sub Aceptar_Click()
Dim fila1 As Long
Dim ws As Worksheet
Set ws = Worksheets(2)
Range("B2").Select
'encontrar sig. Fila vacia
If Sheets("Egr").Range("B3") = "" Then
fila1 = ws.Cells(Rows.Count, 9).End(xlUp).Offset(0, 0).Row
Else
fila1 = ws.Cells(Rows.Count, 9).End(xlUp).Offset(1, 0).Row
End If
'Desproteger Hoja Activa
ActiveSheet.Unprotect "2704"
'pasar datos a bdclientes
ws.Cells(fila1, 2).Value = Me.TextBox1.Value
ws.Cells(fila1, 3).Value = Me.TextBox2.Value
ws.Cells(fila1, 4).Value = Me.ComboBox1.Value
ws.Cells(fila1, 5).Value = Me.ComboBox2.Value
ws.Cells(fila1, 6).Value = Me.TextBox6.Value
ws.Cells(fila1, 7).Value = Me.TextBox7.Value
ws.Cells(fila1, 8).Value = Me.TextBox19.Value
ws.Cells(fila1, 9).Value = Me.TextBox8.Value
ws.Cells(fila1, 10).Value = Me.TextBox10.Value
ws.Cells(fila1, 11).Value = Me.TextBox11.Value
ws.Cells(fila1, 12).Value = Me.TextBox12.Value
ws.Cells(fila1, 13).Value = Me.TextBox13.Value
ws.Cells(fila1, 14).Value = Me.TextBox14.Value
ws.Cells(fila1, 15).Value = Me.ComboBox3.Value
ws.Cells(fila1, 16).Value = Me.TextBox17.Value
ws.Cells(fila1, 17).Value = Me.ComboBox4.Value
'Proteger Hoja Activa
ActiveSheet.Protect "2704", DrawingObjects:=True, Contents:=True, Scenarios:= _
True, AllowFiltering:=True
'limpiar formulario
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.ComboBox1.Value = ""
Me.ComboBox2.Value = ""
Me.TextBox6.Value = ""
Me.TextBox7.Value = ""
Me.TextBox8.Value = ""
Me.TextBox9.Value = ""
Me.TextBox19.Value = ""
Me.TextBox10.Value = ""
Me.TextBox11.Value = ""
Me.TextBox12.Value = ""
Me.TextBox13.Value = ""
Me.TextBox14.Value = ""
Me.ComboBox3.Value = ""
Me.TextBox17.Value = ""
Me.ComboBox4.Value = ""
Me.TextBox1.SetFocus
End Sub
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
On Error Resume Next
TextBox2.Text = Format(CDate(TextBox2), "dd/mm/yy")
If Err <> 0 Then
MsgBox ("Debe ingresar los valores con formato dd/mm/aa"), vbRetryCancel, ATENCION
Cancel = True
End If
End Sub
Private Sub TextBox7_AfterUpdate()
TextBox7 = FormatNumber(CDbl(TextBox7.Value), 2)
End Sub
Private Sub TextBox10_AfterUpdate()
TextBox10 = FormatNumber(CDbl(TextBox10.Value), 2)
End Sub
Private Sub TextBox11_AfterUpdate()
TextBox11 = FormatNumber(CDbl(TextBox11.Value), 2)
End Sub
Private Sub TextBox12_AfterUpdate()
TextBox12 = FormatNumber(CDbl(TextBox12.Value), 2)
End Sub
Private Sub TextBox13_AfterUpdate()
TextBox13 = FormatNumber(CDbl(TextBox13.Value), 2)
End Sub
Private Sub ComboBox1_Enter()
ComboBox1.RowSource = "TbProveedores"
End Sub
Private Sub ComboBox2_Enter()
ComboBox2.RowSource = "TbComprasGastos"
End Sub
Private Sub ComboBox3_Enter()
ComboBox3.RowSource = "Tabla3"
End Sub
Private Sub ComboBox4_Enter()
ComboBox4.RowSource = "Tabla5"
End Sub
Private Sub TextBox7_Change()
TextBox8.Text = Format((TextBox7.Text) * Val(TextBox19) / 100, "#,##0.00")
TextBox9.Text = Format(Val(TextBox7 * 1) + (TextBox8), "#,##0.00")
End Sub
Private Sub TextBox19_Change()
TextBox8.Text = Format((TextBox7.Text) * Val(TextBox19) / 100, "#,##0.00")
TextBox9.Text = Format(Val(TextBox7 * 1) + (TextBox8), "#,##0.00")
End Sub
Private Sub TextBox9_Change()
TextBox14 = Format((TextBox9) - Val(TextBox10) - Val(TextBox11) - Val(TextBox12) + Val(TextBox13), "#,##0.00")
End Sub
Private Sub TextBox10_Change()
TextBox14 = Format((TextBox9) - Val(TextBox10) - Val(TextBox11) - Val(TextBox12) + Val(TextBox13), "#,##0.00")
End Sub
Private Sub TextBox11_Change()
TextBox14 = Format((TextBox9) - Val(TextBox10) - Val(TextBox11) - Val(TextBox12) + Val(TextBox13), "#,##0.00")
End Sub
Private Sub TextBox12_Change()
TextBox14 = Format((TextBox9) - Val(TextBox10) - Val(TextBox11) - Val(TextBox12) + Val(TextBox13), "#,##0.00")
End Sub
Private Sub TextBox13_Change()
TextBox14 = Format((TextBox9) - Val(TextBox10) - Val(TextBox11) - Val(TextBox12) + Val(TextBox13), "#,##0.00")
End Sub
1 respuesta
Respuesta
1