Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub LeasePriceModel_Button2_Click()
- currentWs = 15
- currentItem = 16
- lpmItem = 16
- standardSheetNumber = 15
- mySheets = Worksheets.Count
- firstProduct = 0
- lastProduct = 14
- StandardRowsPCList = 15
- StandardRowsInSheet = 15
- equipmentSheet = 2
- productListEnd = Sheets(2).Range("E16").End(xlDown).Row - StandardRowsPCList
- itemsInSheet = 0
- filledItems = 0
- For i = standardSheetNumber To mySheets
- Sheets(currentWs).Activate
- itemsInSheet = Sheets(currentWs).Range("A16").End(xlDown).Row - StandardRowsInSheet
- For j = 0 To productListEnd - 1
- ProductCode = Sheets(equipmentSheet).Cells(currentItem + j, 5).Value
- productQty = Sheets(equipmentSheet).Cells(currentItem + j, 1).Value
- productCost = Sheets(equipmentSheet).Cells(currentItem + j, 10).Value
- For k = firstProduct To itemsInSheet
- If Sheets(currentWs).Cells(currentItem + k, 4).Value <> 1 Then
- pcToCheck = Sheets(currentWs).Cells(currentItem + k, 1).Value
- If pcToCheck = ProductCode Then
- Sheets(currentWs).Cells(currentItem + k, 6).Value = productCost
- Sheets(currentWs).Cells(currentItem + k, 4).Value = Sheets(currentWs).Cells(currentItem + k, 4).Value + 1
- Exit For
- End If
- End If
- Next k
- filledItems = WorksheetFunction.Sum(Sheets(currentWs).Range(Cells(16, 4), Cells(16 + itemsInSheet, 4)))
- If filledItems = itemsInSheet Then
- totalPrice = WorksheetFunction.Sum(Sheets(currentWs).Range(Cells(16, 6), Cells(16 + itemsInSheet, 6)))
- Sheets(6).Cells(lpmItem, 15).Value = totalPrice
- lpmItem = lpmItem + 2
- Exit For
- End If
- Next j
- If currentWs < mySheets Then
- currentWs = currentWs + 1
- Else
- Sheets(6).Activate
- End If
- Next i
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement