Código:
-----
Sub validar_datos(tb1 As MSForms.TextBox, tb2 As MSForms.TextBox, _
tb3 As MSForms.TextBox, tb4 As MSForms.TextBox, _
sht As String, cel As String, lna As String, _
tx1 As String, tx1a As String, tx2 As String, tx2a As String)
Dim rng As Range
Set rng = Sheets(sht).Range(cel)
'
If tb1 < > Empty And tb2 = "" Then
MsgBox "Falta la fecha del folio 1 en la linea " & lna, vbExclamation, "Falta Fecha"
tb2.SetFocus
ElseIf tb1 < > Empty And tb2 < > Empty And tb3 = "" Then
rng.Value = tx1 & tb1 & tx1a & tb2
ElseIf tb1 < > Empty And tb2 < > Empty And tb3 < > Empty And tb4 = "" Then
MsgBox "Falta la fecha del folio 2 en la linea " & lna, vbExclamation, "Falta Fecha"
tb4.SetFocus
ElseIf tb1 < > Empty And tb2 < > Empty And tb3 < > Empty And tb4 < > Empty Then
rng.Value = tx2 & tb1 & ", " & tb3 & tx2a & tb2 & ", " & tb4
Else
'
End If
End Sub
'
Private Sub CommandButton1_Click()
Call validar_datos(TextBox1, TextBox2, TextBox3, TextBox4, "FORMATO", "F18", "1", _
texto1, texto1a, texto2, texto2a)
'
Call validar_datos(TextBox5, TextBox6, TextBox7, TextBox8, "FORMATO", "F19", "2", _
texto3, texto3a, texto4, texto4a)
'
Call validar_datos(TextBox9, TextBox10, TextBox11, TextBox12, "FORMATO", "F20", "3", _
texto5, texto5a, texto6, texto6a)
'
'
'repetir las 15 veces...
'
End Sub
tb3 As MSForms.TextBox, tb4 As MSForms.TextBox, _
sht As String, cel As String, lna As String, _
tx1 As String, tx1a As String, tx2 As String, tx2a As String)
Dim rng As Range
Set rng = Sheets(sht).Range(cel)
'
If tb1 < > Empty And tb2 = "" Then
MsgBox "Falta la fecha del folio 1 en la linea " & lna, vbExclamation, "Falta Fecha"
tb2.SetFocus
ElseIf tb1 < > Empty And tb2 < > Empty And tb3 = "" Then
rng.Value = tx1 & tb1 & tx1a & tb2
ElseIf tb1 < > Empty And tb2 < > Empty And tb3 < > Empty And tb4 = "" Then
MsgBox "Falta la fecha del folio 2 en la linea " & lna, vbExclamation, "Falta Fecha"
tb4.SetFocus
ElseIf tb1 < > Empty And tb2 < > Empty And tb3 < > Empty And tb4 < > Empty Then
rng.Value = tx2 & tb1 & ", " & tb3 & tx2a & tb2 & ", " & tb4
Else
'
End If
End Sub
'
Private Sub CommandButton1_Click()
Call validar_datos(TextBox1, TextBox2, TextBox3, TextBox4, "FORMATO", "F18", "1", _
texto1, texto1a, texto2, texto2a)
'
Call validar_datos(TextBox5, TextBox6, TextBox7, TextBox8, "FORMATO", "F19", "2", _
texto3, texto3a, texto4, texto4a)
'
Call validar_datos(TextBox9, TextBox10, TextBox11, TextBox12, "FORMATO", "F20", "3", _
texto5, texto5a, texto6, texto6a)
'
'
'repetir las 15 veces...
'
End Sub
-----
No hay comentarios.:
Publicar un comentario