Advertisement
Guest User

Untitled

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