Advertisement
Guest User

Untitled

a guest
May 21st, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Align columns
  2. Columns("A").ColumnWidth = 1.67
  3. Columns("B").ColumnWidth = 3.11
  4. Columns("C").ColumnWidth = 13.67
  5. Columns("D").ColumnWidth = 6.11
  6. Columns("E").ColumnWidth = 32.89
  7. Columns("F").ColumnWidth = 6.56
  8. Columns("G").ColumnWidth = 15.33
  9. Columns("H").ColumnWidth = 11.78
  10. Columns("I").ColumnWidth = 1.56
  11.  
  12.  
  13. 'Align Header Rows
  14. Rows(1).RowHeight = 11.4
  15. Rows(2).RowHeight = 10.8
  16. Rows(3).RowHeight = 19.2
  17. Rows(4).RowHeight = 21
  18. Rows(5).RowHeight = 14.4
  19. Rows(6).RowHeight = 14.4
  20. Rows(7).RowHeight = 12
  21. Rows(8).RowHeight = 12
  22. Rows(9).RowHeight = 12
  23. Rows(10).RowHeight = 12
  24. Rows(11).RowHeight = 12
  25. Rows(12).RowHeight = 27
  26. Rows(13).RowHeight = 14.4
  27. Rows(14).RowHeight = 14.4
  28.  
  29.  
  30.  
  31. 'Get Account info for Header
  32. 'acctName = Sheets(1).Cells(21, 2).Value
  33. 'acctAddy = Sheets(1).Cells(22, 2).Value
  34. 'acctCity = Sheets(1).Cells(24, 2).Value
  35. 'acctProv = Sheets(1).Cells(26, 2).Value
  36. 'acctPostal = Sheets(1).Cells(27, 2).Value
  37. 'acctContact = Sheets(1).Cells(30, 4).Value
  38. 'acctPhone = Sheets(1).Cells(28, 4).Value
  39. 'acctFax = Sheets(1).Cells(29, 4).Value
  40. 'acctEmail = Sheets(1).Cells(31, 4).Value
  41. 'acctRep = Sheets(1).Cells(12, 2).Value
  42. 'Inject account info into Header
  43. 'Cells(7, 4).Value = acctName
  44.  
  45.  
  46. Dim thisModel As String
  47. Dim lastModel As String
  48. Dim lastLocation As String
  49. Dim thisTax As Double
  50. Dim onTax As Double
  51. Dim bcTax As Double
  52. Dim mbTax As Double
  53. Dim nfTax As Double
  54. Dim ntTax As Double
  55. Dim nsTax As Double
  56. Dim nuTax As Double
  57. Dim peTax As Double
  58. Dim qcTax As Double
  59. Dim skTax As Double
  60. Dim ykTax As Double
  61.  
  62.  
  63.  
  64. 'Sales tax Rates
  65. abTax = 0.05
  66. bcTax = 0.12
  67. mbTax = 0.13
  68. nbTax = 0.15
  69. nfTax = 0.15
  70. ntTax = 0.05
  71. nsTax = 0.15
  72. nuTax = 0.05
  73. onTax = 0.13
  74. peTax = 0.13
  75. qcTax = 0.14975
  76. skTax = 0.11
  77. ykTax = 0.05
  78.  
  79.  
  80.  
  81. machineIndex = 16
  82. modelQty = Sheets(2).Cells(machineIndex, 27).Value
  83. moduleStart = 13
  84. modelsToCheckStart = 33
  85. standardSheetNumber = 16
  86. mySheets = Worksheets.Count
  87. statndardRowsInModelDesc = 15
  88. modelTypes = Sheets(2).Cells(Rows.Count, "AB").End(xlUp).Row - statndardRowsInModelDesc
  89.  
  90.  
  91.  
  92. For i = standardSheetNumber To mySheets
  93.        
  94.     'Get
  95.    thisLocation = Sheets(i).Cells(8, 2).Value
  96.     thisProv = Sheets(i).Cells(10, 2).Value
  97.     thisModel = Sheets(i).Cells(16, 2).Value
  98.  
  99.  
  100.     'if address of this machine matches address of the last machine, check if the machine is the same model
  101.    If thisLocation <> lastLocation Or thisModel <> lastModel Then
  102.    
  103.         'Set Quantity
  104.        Cells(moduleStart, 2).Value = 1
  105.    
  106.         'Set Location
  107.        Cells(moduleStart, 5).Value = thisLocation & " - " & thisProv
  108.        
  109.         'Set Province
  110.        Cells(moduleStart, 6).Value = thisProv
  111.  
  112.         'Set Model
  113.        Cells(moduleStart, 3).Value = thisModel
  114.        
  115.         'Set Tax
  116.        Select Case thisProv
  117.             Case "ON"
  118.                 thisTax = onTax
  119.             Case "BC"
  120.                 thisTax = bcTax
  121.             Case "MB"
  122.                 thisTax = mbTax
  123.             Case "NB"
  124.                 thisTax = nbTax
  125.             Case "NF"
  126.                 thisTax = nfTax
  127.             Case "NT"
  128.                 thisTax = ntTax
  129.             Case "NS"
  130.                 thisTax = nsTax
  131.             Case "NU"
  132.                 thisTax = nuTax
  133.             Case "PE"
  134.                 thisTax = peTax
  135.             Case "AB"
  136.                 thisTax = abTax
  137.             Case "QC"
  138.                 thisTax = qcTax
  139.             Case "SK"
  140.                 thisTax = skTax
  141.             Case "YK"
  142.                 thisTax = ykTax
  143.         End Select
  144.            
  145.         'if quantity < 1 then add 1 to machineIndex
  146.        If modelQty <= 1 Then
  147.             machineIndex = machineIndex + 1
  148.         Else
  149.             modelQty = modelQty - 1
  150.         End If
  151.  
  152.         'Increment line pointer
  153.        moduleStart = moduleStart + 1
  154.        
  155.         lastLocation = thisLocation
  156.         lastModel = thisModel
  157.  
  158.     Else
  159.         'increment Qty and move to the next iteration
  160.       Cells(moduleStart - 1, 2).Value = Cells(moduleStart - 1, 2).Value + 1
  161.     End If
  162.    
  163.    
  164.     For j = 0 To modelTypes - 1
  165.         modelToCheck = Sheets(2).Cells(modelsToCheckStart + j, 18).Value
  166.        
  167.         If thisModel = modelToCheck Then
  168.             ' set amount
  169.            Cells(moduleStart - 1, 7).Value = Sheets(2).Cells(modelsToCheckStart + j, 20).Value / Sheets(2).Cells(modelsToCheckStart + j, 16).Value
  170.             Cells(moduleStart - 1, 8).Value = Cells(moduleStart - 1, 7).Value * thisTax
  171.             Exit For
  172.         End If
  173.     Next j
  174.    
  175.     'Multiply amount by quantity
  176.    Cells(moduleStart - 1, 7).Value = Cells(moduleStart - 1, 7).Value * Cells(moduleStart - 1, 2).Value
  177.     Cells(moduleStart - 1, 8).Value = Cells(moduleStart - 1, 8).Value * Cells(moduleStart - 1, 2).Value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement