.Protect
End Sub
Sub editRecord ()
If (ActiveCell.row <5) Or (Len (ActiveCell.EntireRow.Cells (, 1). Value) = 0) Then
Exit Sub
End If
ThisWorkbook.ActiveSheet.Unprotect
editRowForm.Show vbModal
ThisWorkbook.ActiveSheet.Protect
End Sub
Sub sort ()
ThisWorkbook.ActiveSheet.Unprotect
sortForm.Show vbModal
ThisWorkbook.ActiveSheet.Protect
End Sub
Sub report ()
Dim oldCell As Range
ThisWorkbook.ActiveSheet.Unprotect
Set oldCell = ActiveCell
reportForm.Show vbModal
oldCell.Activate
ThisWorkbook.ActiveSheet.Protect
End Sub
addRowForm
Private Sub UserForm_Activate ()
FamBox.Value = ""
ImBox.Value = ""
OtBox.Value = ""
StreetBox.Value = ""
NoBox.Value = ""
FlatBox.Value = ""
PhoneBox.Value = ""
FamBox.SetFocus
End Sub
Private Sub CancelButton_Click ()
addRowForm.Hide
End Sub
Private Sub OKButton_Click ()
'Перевірка інформації
Dim box As Variant, boxes As Variant
boxes = Array (FamBox, ImBox, OtBox, StreetBox, NoBox, PhoneBox)
For Each box In boxes
If Len (Trim (box.Value)) = 0 Then
box.SetFocus
Exit Sub
End If
Next box
If Len (Trim (PhoneBox.Value))> 10 Then
MsgBox "Більше 10 цифр у номері телефону"
PhoneBox.SetFocus
Else
'Заповнення запису з форми
Dim myRecord As Record
myRecord.Fam = FamBox.Value
myRecord.Im = ImBox.Value
myRecord.Ot = OtBox.Value
myRecord.street = StreetBox.Value
myRecord.no = NoBox.Value
myRecord.Flat = FlatBox.Value
myRecord.Phone = Val (PhoneBox.Value)
'Додавання рядка на лист і її заповнення
ActiveCell.EntireRow.Insert
putRecord ActiveCell.EntireRow, myRecord
'Приховання форми
addRowForm.Hide
End If
End Sub
Private Sub PhoneBox_KeyPress (ByVal KeyAscii As MSForms.ReturnInteger)
If (KeyAscii Asc ("9")) Then
MsgBox "Допускається введення тільки цифр!"
KeyAscii.Value = 0
End If
End Sub
h2> delRowForm
Private Sub CancelButton_Click ()
delRowForm.Hide
End Sub
Private Sub OKButton_Click ()
'Видалення поточного рядка
ActiveCell.EntireRow.Delete
'Приховання форми
delRowForm.Hide
End Sub
Private Sub UserForm_Activate ()
Dim myRecord As Record
myRecord = getRecord (ActiveCell.EntireRow)
FamBox.Value = myRecord.Fam
ImBox.Value = myRecord.Im
OtBox.Value = myRecord.Ot
StreetBox.Value = myRecord.street
NoBox.Value = myRecord.no
FlatBox.Value = myRecord.Flat
PhoneBox.Value = myRecord.Phone
OKButton.SetFocus
End Sub
editRowForm
Private Sub UserForm_Activate ()
Dim myRecord As Record
myRecord = getRecord (ActiveCell.EntireRow)...