Проблема Cells(lastrow + 1, 0)
.
Cells
используется как Cells(row, column)
, но нумерация столбцов начинается с 1
, а столбец 0
не существует.
Более того, вы можете уменьшить свой код, используя С оператором и функцией IIf :
Private Sub cmdAddData_Click()
With ThisWorkbook.Worksheets("00. Active Customers")
lastrow = .Cells(.Rows.Count, 1).End(xlUp).Row
.Cells(lastrow + 1, 0).Value = txtDate.Text '<-- column number must be fixed
.Cells(lastrow + 1, 1).Value = txtName.Text
'after 34 textboxes, now for checkboxes
.Cells(lastrow + 1, 35).Value = IIf(cbxADSL.Value, "Yes", "No")
.Cells(lastrow + 1, 36).Value = IIf(cbxAlarm.Value, "Yes", "No")
'after checkboxes, now for textboxes
.Cells(lastrow + 1, 122).Value = txtFirstContact.Text
.Cells(lastrow + 1, 123).Value = txtLastContact.Text
End With
End Sub