Код |
---|
Private Sub CommandButton1_Click() Dim ws As Worksheet Dim lastRow As Long Dim foundRow As Long Dim i As Long Set ws = Sheets("Äàííûå") lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row foundRow = 0 ' Ïîèñê ñîâïàäåíèÿ ïî "Äàòå" è "Ñìåíå" For i = 1 To lastRow If ws.Cells(i, 1).Value = TextBox17.Value And _ UCase(Trim(ws.Cells(i, 4).Value)) = UCase(Trim(ComboBox3.Value)) Then foundRow = i Exit For End If Next i If foundRow > 0 Then With ws .Cells(foundRow, 1).Value = TextBox17.Value .Cells(foundRow, 3).Value = ComboBox1.Value .Cells(foundRow, 4).Value = ComboBox3.Value .Cells(foundRow, 5).Value = TB_Personal.Value .Cells(foundRow, 6).Value = TB_Personal_h.Value .Cells(foundRow, 7).Value = TB_AY.Value .Cells(foundRow, 8).Value = TB_AY_h.Value .Cells(foundRow, 10).Value = TB_Auto.Value .Cells(foundRow, 9).Value = TB_Zakaz.Value .Cells(foundRow, 11).Value = TB_Poz.Value .Cells(foundRow, 12).Value = TB_Ves.Value .Cells(foundRow, 13).Value = TB_OFO.Value .Cells(foundRow, 14).Value = TB_Pret.Value .Cells(foundRow, 15).Value = TB_Problem_Pers.Value .Cells(foundRow, 16).Value = TB_Problem_IT.Value .Cells(foundRow, 17).Value = TB_Problem_dr.Value Îò÷åò.Hide End With Else lastRow = lastRow + 1 With ws .Cells(lastRow, 1).Value = TextBox17.Value .Cells(lastRow, 3).Value = ComboBox1.Value .Cells(lastRow, 4).Value = ComboBox3.Value .Cells(lastRow, 5).Value = TB_Personal.Value .Cells(lastRow, 6).Value = TB_Personal_h.Value .Cells(lastRow, 7).Value = TB_AY.Value .Cells(lastRow, 8).Value = TB_AY_h.Value .Cells(lastRow, 10).Value = TB_Auto.Value .Cells(lastRow, 9).Value = TB_Zakaz.Value .Cells(lastRow, 11).Value = TB_Poz.Value .Cells(lastRow, 12).Value = TB_Ves.Value .Cells(lastRow, 13).Value = TB_OFO.Value .Cells(lastRow, 14).Value = TB_Pret.Value .Cells(lastRow, 15).Value = TB_Problem_Pers.Value .Cells(lastRow, 16).Value = TB_Problem_IT.Value .Cells(lastRow, 17).Value = TB_Problem_dr.Value Îò÷åò.Hide End With End If Unload Me End Sub |
вот так вроде работает
Экономьте электричество!
Отключите NumLock!
Отключите NumLock!