Dim i As Long
Option Explicit
Public Sub CommandButton1_Click()
Sheets("Base de datos").Activate
If fecha = "" Or numeroot = "" Or nombresocio = "" _
Or telefono = "" Or nodo = "" Then
MsgBox "Está dejando campos requeridos vacios favor complete", vbExclamation, "Datos solicitados por OTRS"
nombresocio.SetFocus
Else
'Declaración de variables
'
Dim strTitulo As String
Dim Continuar As String
Dim TransRowRng As Range
Dim NewRow As Integer
Dim Limpiar As String
Dim fila As Integer
Dim final As Integer
Dim i As Integer
Dim VAR2 As Integer
Dim VAR3 As Integer
'
strTitulo = "Atención Usuario OTRS"
'
Continuar = MsgBox("Dara de alta los datos?", vbYesNo + vbExclamation, "Atención Usuario OTRS")
If Continuar = vbNo Then Exit Sub
'
Set TransRowRng = ThisWorkbook.Worksheets("Base de datos").Cells(1, 1).CurrentRegion
NewRow = TransRowRng.Rows.Count + 1
With ThisWorkbook.Worksheets("Base de datos")
.Cells(NewRow, 1).Value = fecha.Value
.Cells(NewRow, 2).Value = fecha.Value
.Cells(NewRow, 3).Value = numeroot.Value
.Cells(NewRow, 4).Value = nombresocio.Value
.Cells(NewRow, 5).Value = tipoot.Value
.Cells(NewRow, 6).Value = empresa.Value
.Cells(NewRow, 7).Value = telefono.Value
.Cells(NewRow, 8).Value = nodo.Value
.Cells(NewRow, 9).Value = solucion.Value
.Cells(NewRow, 10).Value = estadoot.Value
.Cells(NewRow, 11).Value = nota.Value
.Cells(NewRow, 12).Value = motivo.Value
.Cells(NewRow, 13).Value = unidadmovil.Value
.Cells(NewRow, 14).Value = empleado1.Value
.Cells(NewRow, 15).Value = empleado2.Value
.Cells(NewRow, 16).Value = recibo.Value
.Cells(NewRow, 17).Value = mac.Value
.Cells(NewRow, 18).Value = series.Value
.Cells(NewRow, 19).Value = trabajosolo.Value
.Cells(NewRow, 20).Value = pagardoble.Value
.Cells(NewRow, 21).Value = comentariofinal.Value
Range("A" & Cells.Rows.Count).End(xlUp).Offset(1).Select
fila = 2
For i = 0 To cajamateriales.ListCount - 1
Hoja1.Cells(fila, 22).Value = cajamateriales.List(i, 0)
fila = fila + 1
Next
fila = 2
For i = 0 To cajamateriales.ListCount - 1
Hoja1.Cells(fila, 23).Value = cajacantidadmateriales.List(i, 0)
fila = fila + 1
Next
fila = 2
For i = 0 To cajalabores.ListCount - 1
Hoja1.Cells(fila, 24).Value = cajalabores.List(i, 0)
fila = fila + 1
Next
fila = 2
For i = 0 To cajacantidadlabores.ListCount - 1
Hoja1.Cells(fila, 25).Value = cajacantidadlabores.List(i, 0)
fila = fila + 1
Next
MsgBox "OT ingresada exitosamente", vbInformation, "Atención Usuario OTRS"
cajamateriales.Clear 'Limpiamos el listbox
i = 0 'reiniciamos el indice de registros del listbox
listamateriales.SetFocus 'enviamos el foco al control
cajalabores.Clear 'Limpiamos el listbox
i = 0 'reiniciamos el indice de registros del listbox
listalabores.SetFocus 'enviamos el foco al control
cajacantidadlabores.Clear 'Limpiamos el listbox
cajacantidadmateriales.Clear 'Limpiamos el listbox
fecha.Value = ""
numeroot.Value = ""
nombresocio.Value = ""
tipoot.Value = ""
empresa.Value = ""
telefono.Value = ""
nodo.Value = ""
solucion.Value = ""
estadoot.Value = ""
nota.Value = ""
motivo.Value = ""
unidadmovil.Value = ""
empleado1.Value = ""
empleado2.Value = ""
recibo.Value = ""
mac.Value = ""
series.Value = ""
trabajosolo.Value = ""
pagardoble.Value = ""
comentariofinal.Value = ""
cajamateriales.Value = ""
cajalabores.Value = ""
cantidadmateriales.Value = ""
cantidadlabores.Value = ""
listamateriales.Value = ""
listalabores.Value = ""
fecha.SetFocus
End With
End If
End Sub