- Código: Seleccionar todo
Private Sub guardar_datos()
Dim col As Variant
Dim fila As Variant
Dim cod_int As Variant
Sheets("Datos").Activate
fila = ActiveCell.Row
col = ActiveCell.Column
fechaini = UserForm1.fecha_inicio.Value
fechafin = UserForm1.fecha_fin.Value
mes_ini = Month(fechaini)
mes_fin = Month(fechafin)
cod_int = "R-" & fila - 1 'generamos el codigo interno
ActiveCell.Offset(0, 0).Value = cod_int
ActiveCell.Offset(0, 1).Value = UserForm1.agencia.Text
ActiveCell.Offset(0, 2).Value = UserForm1.cod_reserv.Text
ActiveCell.Offset(0, 3).Value = UserForm1.pax.Text
ActiveCell.Offset(0, 4).Value = UserForm1.num_pax.Text
ActiveCell.Offset(0, 5).Value = UserForm1.recibo.Text
ActiveCell.Offset(0, 6).Value = UserForm1.monto.Text
ActiveCell.Offset(0, 7).Value = CDate(UserForm1.fecha_pedido.Text)
ActiveCell.Offset(0, 8).Value = CDate(UserForm1.fecha_inicio.Text)
ActiveCell.Offset(0, 9).Value = mes_ini
ActiveCell.Offset(0, 10).Value = CDate(UserForm1.fecha_fin.Text)
ActiveCell.Offset(0, 11).Value = mes_fin
ActiveCell.Offset(0, 12).Value = UserForm1.programa.Text
ActiveCell.Offset(0, 13).Value = UserForm1.categoria.Text
ActiveCell.Offset(0, 14).Value = UserForm1.extension.Text
ActiveCell.Offset(0, 15).Value = UserForm1.personal.Text
ActiveCell.Offset(0, 16).Value = CDate(UserForm1.fecha_entrega.Text)
ActiveCell.Offset(0, 17).Value = UserForm1.fecha_respuesta.Value
ActiveCell.Offset(0, 18).Value = UserForm1.fecha_modif.Value
ActiveCell.Offset(0, 19).Value = UserForm1.fecha_anul.Value
If UserForm1.recibo.Value <> "" Then
Sheets("Datos").Range("V1").Value = UserForm1.recibo.Value
End If
cancelar.Caption = "SALIR"
ActiveWorkbook.Save
End Sub
Como verán los datos los paso uno a uno, acá no es mucho trabajo, pero estoy trabajando en un formulario con muchos mas controles de este tipo y la verdad no me parece la mejor manera de hacerlo, estoy seguro q uno de ustedes conoce alguna forma mas eficiente y agradecería q me ayuden con ello.
saludos.
David




