Sub Order() Dim S1LR As Long With Sheets(2) S1LR = Cells(5, 2) If Cells(3, 2).Value = 0 Then MsgBox ("Введите дату") Cells(3, 2).Select Exit Sub End If If Sheets(1).Cells(S1LR, 4) >= Cells(5, 2) Then Sheets(1).Cells(S1LR, 4) = Sheets(1).Cells(S1LR, 4) - Cells(5, 2) Else MsgBox "Такого количества в наличии нет" Cells(5, 2).Select
Exit Sub End If If Cells(4, 2).Value = 0 Then MsgBox ("Введите товар из выпадающего списка") Cells(4, 2).Select Exit Sub End If If Cells(5, 2).Value = 0 Then MsgBox ("Введите количество товара ") Cells(5, 2).Select Exit Sub End If End With
S2LR = Sheets(3).Cells(Rows.Count, 1).End(xlUp).Row For i = 2 To S2LR If Sheets(2).Cells(1, 2).Value = Sheets(3).Cells(i, 1).Value _ And Sheets(2).Cells(2, 2).Value = Sheets(3).Cells(i, 2).Value _ And Sheets(2).Cells(3, 2).Value = Sheets(3).Cells(i, 3).Value _ And Sheets(2).Cells(5, 2).Value = Sheets(3).Cells(i, 5).Value _ Then
MsgBox ("Такой заказ уже существует Операция отменена") Exit Sub
Sub Order() Dim S1LR As Long With Sheets(2) S1LR = Cells(5, 2) If Cells(3, 2).Value = 0 Then MsgBox ("Введите дату") Cells(3, 2).Select Exit Sub End If If Sheets(1).Cells(S1LR, 4) >= Cells(5, 2) Then Sheets(1).Cells(S1LR, 4) = Sheets(1).Cells(S1LR, 4) - Cells(5, 2) Else MsgBox "Такого количества в наличии нет" Cells(5, 2).Select
Exit Sub End If If Cells(4, 2).Value = 0 Then MsgBox ("Введите товар из выпадающего списка") Cells(4, 2).Select Exit Sub End If If Cells(5, 2).Value = 0 Then MsgBox ("Введите количество товара ") Cells(5, 2).Select Exit Sub End If End With
S2LR = Sheets(3).Cells(Rows.Count, 1).End(xlUp).Row For i = 2 To S2LR If Sheets(2).Cells(1, 2).Value = Sheets(3).Cells(i, 1).Value _ And Sheets(2).Cells(2, 2).Value = Sheets(3).Cells(i, 2).Value _ And Sheets(2).Cells(3, 2).Value = Sheets(3).Cells(i, 3).Value _ And Sheets(2).Cells(5, 2).Value = Sheets(3).Cells(i, 5).Value _ Then
MsgBox ("Такой заказ уже существует Операция отменена") Exit Sub