=ЕСЛИ(A2="дневное";ЕСЛИ(B2<=5;B2*1;ЕСЛИ(B2<=10;B2*0,8;B2*0,6));ЕСЛИ(B2<=15;B2*0,5;ЕСЛИ(B2<=30;B2*0,3;B2*0,1))) По этой формуле составить макрос в Excel
Dim i As Integer Dim lastRow As Integer Dim ws As Worksheet Set ws = ThisWorkbook.Sheets("Sheet1") lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row For i = 2 To lastRow If ws.Cells(i, 1).Value = "дневное" Then If ws.Cells(i, 2).Value <= 5 Then ws.Cells(i, 3).Value = ws.Cells(i, 2).Value * 1 ElseIf ws.Cells(i, 2).Value <= 10 Then ws.Cells(i, 3).Value = ws.Cells(i, 2).Value * 0.8 Else ws.Cells(i, 3).Value = ws.Cells(i, 2).Value * 0.6 End If ElseIf ws.Cells(i, 2).Value <= 15 Then ws.Cells(i, 3).Value = ws.Cells(i, 2).Value * 0.5 ElseIf ws.Cells(i, 2).Value <= 30 Then ws.Cells(i, 3).Value = ws.Cells(i, 2).Value * 0.3 Else ws.Cells(i, 3).Value = ws.Cells(i, 2).Value * 0.1 End If Next i
Sub РасчетСкидки()
Dim i As IntegerDim lastRow As Integer
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
For i = 2 To lastRow
If ws.Cells(i, 1).Value = "дневное" Then
If ws.Cells(i, 2).Value <= 5 Then
ws.Cells(i, 3).Value = ws.Cells(i, 2).Value * 1
ElseIf ws.Cells(i, 2).Value <= 10 Then
ws.Cells(i, 3).Value = ws.Cells(i, 2).Value * 0.8
Else
ws.Cells(i, 3).Value = ws.Cells(i, 2).Value * 0.6
End If
ElseIf ws.Cells(i, 2).Value <= 15 Then
ws.Cells(i, 3).Value = ws.Cells(i, 2).Value * 0.5
ElseIf ws.Cells(i, 2).Value <= 30 Then
ws.Cells(i, 3).Value = ws.Cells(i, 2).Value * 0.3
Else
ws.Cells(i, 3).Value = ws.Cells(i, 2).Value * 0.1
End If
Next i
End Sub