Hi,
In the code below i am looping through a table finding the rows with particular code (product code) and performing math on another column on that row (units) and adding it to another sheet. The problem i am having is i want the variable 'e20' to be the multiplier 'e202' when a certain number in this case greater than 250 is met. The code below attempts that however if i break this threshold of 250 in the middle of a calculation it does not register that say half of the calculation needs to be at 'e20' and the other at 'e202'. Any advice would be great.
Thanks,
SPM
Sub Check_Sheet()
Dim e20 As Integer
Dim e202 As Integer
e20 = 10
e202 = 20
For Row = 1 To 100
For Col = 1 To 20
If ThisWorkbook.Sheets("Sheet1").Cells(Row, Col).Value = "SEPE1E05X041" Then
If ThisWorkbook.Sheets("Sheet2").Cells(16, 3).Value = 0 Then
ThisWorkbook.Sheets("Sheet2").Cells(16, 4) = ThisWorkbook.Sheets("Sheet2").Cells(16, 4).Value + ThisWorkbook.Sheets("Sheet1").Cells(Row, 13).Value * e20
ThisWorkbook.Sheets("Sheet2").Cells(16, 3) = ThisWorkbook.Sheets("Sheet2").Cells(16, 3).Value + ThisWorkbook.Sheets("Sheet1").Cells(Row, 16).Value
ElseIf ThisWorkbook.Sheets("Sheet2").Cells(16, 3).Value > 250 Then
ThisWorkbook.Sheets("Sheet2").Cells(16, 4) = ThisWorkbook.Sheets("Sheet2").Cells(16, 4).Value + ThisWorkbook.Sheets("Sheet1").Cells(Row, 13).Value * e202
ThisWorkbook.Sheets("Sheet2").Cells(16, 3) = ThisWorkbook.Sheets("Sheet2").Cells(16, 3).Value + ThisWorkbook.Sheets("Sheet1").Cells(Row, 16).Value
End If
End If
Next
Next
End Sub
Bookmarks