Имеется лист "БД" (база данных), к ячейкам "В" (название организаций) которого прикреплена пользовательская форма (расширенные сведения об организации). В случае ликвидации организации все данные о ней должны быть удалены из БД при нажатии кнопки CommandButton6 ("Очистить все", расположенной на форме. Однако вместо этого возникает ошибка '1004' с подсветкой строки ".Cells..."
Помогите, пожалуйста, избавиться от этой напасти. Прошу прощения за слабое знание VBA.
Ниже привожу текст кода, расположенного в модуле листа "БД".
А здесь показан код вызова пользовательской формы.
Помогите, пожалуйста, избавиться от этой напасти. Прошу прощения за слабое знание VBA.
Ниже привожу текст кода, расположенного в модуле листа "БД".
Код |
---|
Private Sub CommandButton6_Click() With Worksheets("БД") .Cells(.iRow1, "F").ClearContents .Cells(.iRow1, "N").ClearContents .Cells(.iRow1, "O").ClearContents .Cells(.iRow, "P").ClearContents .Cells(.iRow, "Q").ClearContents .Cells(.iRow, "R").ClearContents .Cells(.iRow, "S").ClearContents .Cells(.iRow, "T").ClearContents .Cells(.iRow, "U").ClearContents .Cells(.iRow, "V").ClearContents .Cells(.iRow, "W").ClearContents .Cells(.iRow, "X").ClearContents .Cells(.iRow, "Y").ClearContents .Cells(.iRow, "Z").ClearContents .Cells(.iRow, "AA").ClearContents End With Unload Me MsgBox "Данные удалены" End Sub |
А здесь показан код вызова пользовательской формы.
Код |
---|
Public iRow&, iRow1& Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim iRow&: iRow = Target.Row If Not Intersect([H6:H1105], Target) Is Nothing Then If LCase(Trim(Target)) = "ñäåëàíî" Then 'If Target = "ñäåëàíî" Then iRow1 = Target.Row With UserForm2 .TextBox19 = Cells(iRow1, "A") .TextBox20 = Cells(iRow1, "B") .TextBox21 = Cells(iRow1, "F") .TextBox22 = Cells(iRow1, "I") .TextBox23 = Cells(iRow1, "J") .Show End With End If ElseIf Not Application.Intersect(Range("D6:D1105"), Target) Is Nothing Then UserForm1.Show ElseIf Not Application.Intersect(Range("F6:F1105"), Target) Is Nothing Then UserForm1.Show ElseIf Not Intersect([B6:B1105], Target) Is Nothing Then With Card .TextBox1 = Cells(iRow, "A") .TextBox2 = Cells(iRow, "B") .TextBox3 = Cells(iRow, "N") .TextBox4 = Cells(iRow, "O") .TextBox5 = Cells(iRow, "P") .TextBox6 = Cells(iRow, "Q") .TextBox7 = Cells(iRow, "R") .TextBox8 = Cells(iRow, "S") .TextBox9 = Cells(iRow, "T") .TextBox10 = Cells(iRow, "U") .TextBox11 = Cells(iRow, "V") .TextBox12 = Cells(iRow, "W") .TextBox13 = Cells(iRow, "X") .TextBox14 = Cells(iRow, "Y") .TextBox15 = Cells(iRow, "Z") .TextBox16 = Cells(iRow, "AA") .TextBox17 = Cells(iRow, "K") .TextBox18 = Cells(iRow, "L") .Show End With End If End Sub |