Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. currentWs = 16
  2. currentItem = 16
  3. lpmItem = 16
  4. standardSheetNumber = 16
  5. mySheets = Worksheets.Count
  6. firstProduct = 0
  7. lastProduct = 14
  8. StandardRowsPCList = 15
  9. StandardRowsInSheet = 15
  10. equipmentSheet = 2
  11. productListEnd = Sheets(2).Range("E16").End(xlDown).Row - StandardRowsPCList
  12. itemsInSheet = 0
  13. filledItems = 0
  14. lpmSheet = 7
  15.  
  16. For i = standardSheetNumber To mySheets
  17.    
  18.     Sheets(currentWs).Activate
  19.     itemsInSheet = Sheets(currentWs).Range("A16").End(xlDown).Row - StandardRowsInSheet
  20.    
  21.     For j = 0 To productListEnd - 1
  22.    
  23.         ProductCode = Sheets(equipmentSheet).Cells(currentItem + j, 5).Value
  24.         productQty = Sheets(equipmentSheet).Cells(currentItem + j, 1).Value
  25.         productCost = Sheets(equipmentSheet).Cells(currentItem + j, 10).Value
  26.        
  27.         For k = firstProduct To itemsInSheet
  28.             If Sheets(currentWs).Cells(currentItem + k, 4).Value <> 1 Then
  29.                 pcToCheck = Sheets(currentWs).Cells(currentItem + k, 1).Value
  30.  
  31.                 If pcToCheck = ProductCode Then
  32.                     Sheets(currentWs).Cells(currentItem + k, 6).Value = productCost
  33.                     Sheets(currentWs).Cells(currentItem + k, 4).Value = Sheets(currentWs).Cells(currentItem + k, 4).Value + 1
  34.                     Exit For
  35.                 End If
  36.            
  37.             End If
  38.         Next k
  39.        
  40.         filledItems = WorksheetFunction.Sum(Sheets(currentWs).Range(Cells(16, 4), Cells(16 + itemsInSheet, 4)))
  41.        
  42.         If filledItems = itemsInSheet Then
  43.             totalPrice = WorksheetFunction.Sum(Sheets(currentWs).Range(Cells(16, 6), Cells(16 + itemsInSheet, 6)))
  44.             Sheets(lpmSheet).Cells(lpmItem, 15).Value = totalPrice
  45.             lpmItem = lpmItem + 2
  46.             Exit For
  47.         End If
  48.  
  49.     Next j
  50.    
  51.     If currentWs < mySheets Then
  52.         currentWs = currentWs + 1
  53.     Else
  54.         Sheets(lpmSheet).Activate
  55.     End If
  56.  
  57. Next i
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement