Dim wsQuote As Worksheet
Dim wsCalc As Worksheet
MsgBox "WAIT2"
Set wsQuote = Sheets(vpvquotefile)
finalRowQuotePage = wsQuote.Cells(Rows.Count, 1).End(xlUp).Row
For i = 15 To finalRowQuotePage
'This will get 4 vars from CalcTypePage write them to Cols O.P,Q,R
'then get Qty and % from cols 4 & 5 QuotePage and write to Cols S & T
If Left(wsQuote.Cells(i, 3), 1) = "&" Then
vCode = wsQuote.Cells(i, 1)
wsQuote.Cells(i, 20) = wsQuote.Cells(i, 4) 'Qty -usually 1
swsQuote.Cells(i, 21) = wsQuote.Cells(i, 5) '%
Set wsCalc = Sheets("CalcType")
FinalRowCalcType = wsCalc.Cells(Rows.Count, 1).End(xlUp).Row
v = i
For m = 2 To FinalRowCalcType
If vCode = wsCalc.Cells(m, 1) Then
wsQuote.Cells(v, 15) = wsCalc.Cells(m, 1) 'Code
wsQuote.Cells(v, 16) = Val(wsCalc.Cells(m, 2)) 'NumMult
wsQuote.Cells(v, 17) = wsCalc.Cells(m, 3) 'VarMult
wsQuote.Cells(v, 18) = Val(wsCalc.Cells(m, 4)) 'NumDiv
wsQuote.Cells(v, 19) = wsCalc.Cells(m, 5) 'VarDiv
'v = v + 1
End If
Next m
End If
' not sure which sheet Cells is referring to here
If Not Left(Cells(i, 3), 1) = "&" Then
Ans = Ans + Val(Cells(i, 4))
Else
vExcl = vExcl + Val(Cells(i, 4))
End If
Next i
MsgBox ("WAIT PRETOTAL NOW")
finalRowQuotePage = wsQuote.Cells(Rows.Count, 3).End(xlUp).Row
wsQuote.Cells(finalRowQuotePage + 1, 3) = "PRE % TOTAL"
wsQuote.Cells(finalRowQuotePage + 1, 4) = Val(Ans)
wsQuote.Cells(finalRowQuotePage + 2, 3) = "EXCLUSIONS"
wsQuote.Cells(finalRowQuotePage + 2, 4) = Val(vExcl)
Ans = 0
vExcl = 0
‘XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
‘XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
' again, not sure which sheet Cells is supposed to refer to here
If Cells(x, 3) = "PRE % TOTAL" Then
vTotalLine = x + 1 ' XX THIS CAUSES PROBLEM AS IT RETURNS VALUE OF EMPTY
' not sure about this - can't see anywhere in the code that x is given/not given a value
vpretot6 = Val(Cells(x, 6))
vpretot7 = Val(Cells(x, 7))
vpretot8 = Val(Cells(x, 8))
vpretot9 = Val(Cells(x, 9))
End If
Next x
FinalRowQuoteSheet = wsQuote.Cells(Rows.Count, 6).End(xlUp).Row
WriteRow = FinalRowQuoteSheet + 1
For y = vTotalLine To FinalRowQuoteSheet
vTOT6 = vTOT6 + Cells(y, 6) ' XXX THIS IS FALLOVER LINE AS Cells (y,6) has no value
' this could be because there is not worksheet reference the code is
' looking at Cells(y,6) on the wrong worksheet
vTOT7 = vTOT7 + Cells(y, 7)
vTOT8 = vTOT8 + Cells(y, 8)
vTOT9 = vTOT9 + Cells(y, 9)
Next y