Para abrir el form de reservas
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Columns("P")) Is Nothing Then
If Target.Count > 1 Then Exit Sub
If Target.Row < 5 Then Exit Sub
If UCase(Target.Value) <> "NO" Then Exit Sub
UsClien.Show
End If
End Sub
Al momento de abrir el form de reservas
Private Sub UserForm_Initialize()
Label32 = Format(Now, "[$-80A]dddd, dd"" de ""mmmm"" de ""yyyy hh:mm:ss am/pm")
Me.TextBox1.SetFocus
'
'Si la hoja activa es "reservaciones", entonces hay que cambiar el estatus
'a registrado y terminar el registro del cliente
'
If ActiveSheet.Name = "RESERVACIONES" Then
Dim wfila, h, b
wfila = ActiveCell.Row
TextBox1 = Cells(wfila, "B") 'nombre
TextBox2 = Cells(wfila, "C") 'no. document
TextBox9 = Cells(wfila, "H") 'telefono
Habitacion = Left(Cells(wfila, "L"), 3)
tipo = Mid(Cells(wfila, "L"), 4)
Set h = Sheets("habitacion")
Set b = h.Columns("C").Find(Val(Habitacion), lookat:=xlWhole)
If Not b Is Nothing Then
h.Unprotect "5"
h.Cells(b.Row, "F") = "OCUPADA"
h.Protect "5"
End If
End If
End Sub
Para registrar
Private Sub CommandButton1_Click()
'On Error Resume Next
Dim Lin As Integer, a As Integer
If TextBox1 = "" Then
MsgBox "Captura nombre del Huésped", vbOKOnly + vbInformation, "AVISO"
Frame1.TextBox1.SetFocus
Exit Sub
End If
Dim FilaVacia As Long
Dim text13
With ThisWorkbook.Sheets("USUARIOS")
.Unprotect "5"
FilaVacia = .Range("D" & Rows.Count).End(xlUp).Row + 1
.Range("b" & FilaVacia) = Format(FilaVacia - 4, "00000")
.Range("c" & FilaVacia) = Me.TextBox2.Text
.Range("d" & FilaVacia) = Me.TextBox1.Text
.Range("e" & FilaVacia) = Me.ComboBox5
.Range("f" & FilaVacia) = Me.ComboBox1
.Range("g" & FilaVacia) = Me.ComboBox7
.Range("h" & FilaVacia) = Me.TextBox15.Text
.Range("i" & FilaVacia) = Me.ComboBox16
.Range("j" & FilaVacia) = Me.ComboBox9
.Range("k" & FilaVacia) = Me.TextBox8.Text
.Range("l" & FilaVacia) = Me.TextBox11.Text
.Range("m" & FilaVacia) = Me.TextBox12.Text
.Range("n" & FilaVacia) = Me.TextBox10.Text
.Range("o" & FilaVacia) = Me.TextBox9.Text
.Range("p" & FilaVacia) = Habitacion
.Range("q" & FilaVacia) = Me.ComboBox2
.Range("r" & FilaVacia) = tipo
.Range("s" & FilaVacia) = Me.ComboBox15
.Range("t" & FilaVacia) = Me.DTPicker1
.Range("u" & FilaVacia) = Time
.Range("v" & FilaVacia) = Me.TextBox14.Text
.Range("w" & FilaVacia) = Me.TextBox4.Text
.Range("x" & FilaVacia) = Me.TextBox16.Text
.Range("y" & FilaVacia) = Me.DTPicker2
.Range("z" & FilaVacia) = Me.ComboBox3
.Range("aa" & FilaVacia) = Me.ComboBox4
.Range("ab" & FilaVacia) = TextBox17.Text
.Range("ac" & FilaVacia) = TextBox13.Text
.Range("ad" & FilaVacia) = TextBox18.Text
.Range("ae" & FilaVacia) = ComboBox17
If Me.TextBox13 <> "" Then text13 = CDbl(Me.TextBox13) Else text13 = ""
.Range("ac" & FilaVacia) = text13
With ThisWorkbook.Sheets("Habitacion")
.Unprotect "5"
For a = 5 To 40
If .Range("C" & a) = Habitacion Then Lin = a: Exit For
Next
.Range("G" & Lin) = Me.TextBox4.Text
.Range("H" & Lin) = Me.TextBox14.Text
.Range("J" & Lin) = Date
.Range("I" & Lin) = Me.TextBox16.Text
.Range("K" & Lin) = Me.DTPicker2
.Range("L" & Lin) = Me.TextBox17.Text
.Range("M" & Lin) = Me.ComboBox3
.Range("O" & Lin) = Me.TextBox18.Text
.Range("p" & Lin) = Me.TextBox1.Text
.Range("Q" & Lin) = CDbl(Me.TextBox13.Text)
End With
.Protect "5"
End With
'
'cambia el estatus en reserva
If ActiveSheet.Name = "RESERVACIONES" Then
Dim wfila
wfila = ActiveCell.Row
ActiveSheet.Unprotect "5"
Cells(wfila, "P") = "SI"
ActiveSheet.Protect "5"
End If
Registrado = True
MsgBox "datos registrados correctamente"
Unload Me
End Sub
Sal u dos