VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} cellsProperty 
   Caption         =   "Дополнительные сойства ячейки"
   ClientHeight    =   2220
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   3960
   OleObjectBlob   =   "cellsProperty.frx":0000
   StartUpPosition =   1  'CenterOwner
End
Attribute VB_Name = "cellsProperty"
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit

Public pMode As Integer ' MODE ячейки
Public cLinkRow As Integer, cLinkCol As Integer, cRazdel As Integer, cRowId As Integer

Private Sub CommandButton1_Click()
    pbFormCancel = True
    pMode = IIf(Me.CheckBox1.value = True, 1, 0) + IIf(Me.CheckBox2.value = True, 2, 0) + IIf(Me.CheckBox3.value = True, 4, 0) + IIf(Me.CheckBox4.value = True, 8, 0)
    Me.Hide
End Sub

Private Sub CommandButton2_Click()
    pbFormCancel = False
    Me.Hide
End Sub

Private Sub UserForm_Activate()
    If (pMode And 1) <> 0 Then Me.CheckBox1.value = True Else Me.CheckBox1.value = False
    If (pMode And 2) <> 0 Then Me.CheckBox2.value = True Else Me.CheckBox2.value = False
    If (pMode And 4) <> 0 Then Me.CheckBox3.value = True Else Me.CheckBox3.value = False
    If (pMode And 8) <> 0 Then Me.CheckBox4.value = True Else Me.CheckBox4.value = False
End Sub

'Установка доп. св-в ячейки (номер строки, номер графы)
Public Sub changeCellsProperty(row As Integer, column As Integer)
Dim sheetsService, LookRange
    Set sheetsService = Sheets("Service")
    
    cLinkRow = Sheets(sheetsService.Range("B19").Text).Cells(row, 1)
    cLinkCol = column - sheetsService.Range("C6") + 1
    cRazdel = sheetsService.Range("B20")
    With sheetsService.Range("KRIT_CELLS_PROP")
        sheetsService.Cells(.row + 1, .column) = cLinkRow
        sheetsService.Cells(.row + 1, .column + 1) = cLinkCol
        sheetsService.Cells(.row + 1, .column + 2) = cRazdel
        
        If sheetsService.Cells(.row + 2, .column + 1) = 1 Then
            pMode = 0
            cRowId = 0
        Else
            pMode = sheetsService.Cells(.row + 4, .column)
            cRowId = sheetsService.Cells(.row + 5, .column)
        End If
    End With
    Load cellsProperty
    cellsProperty.Show
    If pbFormCancel Then
        With sheetsService.Range("TABLE_CELLS_PROP")
            If pMode = 0 Then
                If cRowId <> 0 Then sheetsService.Range(sheetsService.Cells(cRowId, .column), sheetsService.Cells(cRowId, .column + .Columns.count - 1)).Delete Shift:=xlUp
            Else
                If cRowId = 0 Then
                    Set LookRange = sheetsService.Columns(.column).Find("", LookIn:=xlFormulas, lookat:=xlWhole, SearchOrder:=xlByRows)
                    cRowId = LookRange.row
                End If
                sheetsService.Cells(cRowId, .column) = cLinkRow
                sheetsService.Cells(cRowId, .column + 1) = cLinkCol
                sheetsService.Cells(cRowId, .column + 2) = cRazdel
                sheetsService.Cells(cRowId, .column + 3) = pMode
                '.Cells(cRowId, .column + 4) = cLinkRow
                sheetsService.Cells(cRowId, .column + 4).FormulaLocal = "=СТРОКА()"
            End If
        End With
    End If
    Unload cellsProperty
End Sub


