|
Muchas gracias por tu ayuda y pronta colaboración, el codigo que me enviaste me sirvio aunque no lo tome literal pero me ayudo mucho, bien ahora me he topado con un problemilla que si eres tan amable de ayudarme ya que en el codigo yo lo cambie por Me.TextBox4.SetFocus ahora el problema es que he intentado de mil maneras pero el cursor siempre se va al TextBox3 en vez del TextBox4 y no se porqué, tengo un codigo que al dejarlo en blanco me anota "Anulada" en el TextBox1, y del TextBox2 al TextBox4, me anote "0.00" pero en realidad lo que yo quiero es que al dejarlo en blanco haga lo anterior pero que se valla al CommandButton1 que tengo, pero como no se como hacerlo, pues opte para que se fuera al TextBox4, pero repito no se porque siempre se queda en el TextBox3, si pudieras ayudarme te lo agradecería, además te envio todo el codigo que tengo para ver si tu podrias encontrar donde esta mi error:
Private Sub CommandButton1_Click()
Rem inserta un renglon
Fila = 9
Col = 2
While Cells(Fila, Col) <> Empty
Fila = Fila + 1
Wend
Cells(Fila, 2) = TextBox1
Cells(Fila, 4) = Val(TextBox2)
Cells(Fila, 6) = Val(TextBox3)
Cells(Fila, 8) = Val(TextBox4)
TextBox1 = Empty
TextBox2 = Empty
TextBox3 = Empty
TextBox4 = Empty
TextBox1.SetFocus
End Sub
Private Sub TextBox1_Change()
largo_entrada = Len(Me.TextBox1)
Select Case largo_entrada
Case 2
Me.TextBox1.Value = Me.TextBox1.Value & "/"
Case 5
Me.TextBox1.Value = Me.TextBox1.Value & "/" & Year(Date)
TextBox2.SetFocus
End Select
End Sub
Private Sub TextBox2_Change()
Range("D8").Select
ActiveCell.FormulaR1C1 = TextBox2
End Sub
Private Sub TextBox3_Change()
Range("F8").Select
ActiveCell.FormulaR1C1 = TextBox3
End Sub
Private Sub TextBox4_Change()
Range("H8").Select
ActiveCell.FormulaR1C1 = TextBox4
End Sub
Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 27 Then
UserForm1.Hide
End If
End Sub
Private Sub TextBox2_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 27 Then
UserForm1.Hide
End If
End Sub
Private Sub TextBox3_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 27 Then
UserForm1.Hide
End If
End Sub
Private Sub TextBox4_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 27 Then
UserForm1.Hide
End If
End Sub
Private Sub CommandButton1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 27 Then
UserForm1.Hide
End If
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox1.Text = "" Then
TextBox1 = "Anulada"
TextBox2 = "0.00"
TextBox3 = "0.00"
TextBox4 = "0.00"
Me.TextBox4.SetFocus
End If
End Sub
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If IsNumeric(TextBox2.Text) Then
TextBox2.Text = Format(TextBox2.Text, "#,##0.00")
Else
TextBox2.Text = "0.00"
End If
End Sub
Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If IsNumeric(TextBox3.Text) Then
TextBox3.Text = Format(TextBox3.Text, "#,##0.00")
Else
TextBox3.Text = "0.00"
End If
End Sub
Private Sub TextBox4_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If IsNumeric(TextBox4.Text) Then
TextBox4.Text = Format(TextBox4.Text, "#,##0.00")
Else
TextBox4.Text = "0.00"
End If
End Sub
|