I was just sent a new workbook with macros to use to track my numbers at my new job. This particular macro is used to combine all the different sheets into one master sheet. When I try to run it, i get runtime error 13:type mismatch. Here is the code from the debugger. The error is coming from between the ** **. I am running excel 2010 on windows 7. PLease help, as I am completely clueless to what's going wrong.
Sub RankManagers()
Dim i, j As Integer
Dim AppTot, PremTot, UWATot As Variant
Range("K1").Select
ActiveCell.FormulaR1C1 = "=COUNTA(R[2]C[-2]:R[4999]C[-2])"
j = Range("K1").Value + 2
i = 3
AppTot = 0
PremTot = 0
UWATot = 0
For i = 3 To j
Cells(i, 8).Value = i - 2
Cells(i, 12).FormulaR1C1 = "=COUNTIF(R3C4:R5000C4,RC[-3])"
**AppTot = AppTot + Cells(i, 10)
PremTot = PremTot + Cells(i, 11)
UWATot = UWATot + Cells(i, 12)**
Next i
Range(Cells(3, 8), Cells(j, 8)).Select
With Selection
.HorizontalAlignment = xlRight
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Columns.AutoFit
Selection.Font.Bold = True
Range("K1").Select
Selection.ClearContents
Range("A1").Select
Cells(j + 1, 9).FormulaR1C1 = "Totals:"
Selection.Font.Bold = True
Cells(j + 1, 10).Value = AppTot
Cells(j + 1, 11).Value = PremTot
Cells(j + 1, 12).Value = UWATot
Sub RankManagers()
Dim i, j As Integer
Dim AppTot, PremTot, UWATot As Variant
Range("K1").Select
ActiveCell.FormulaR1C1 = "=COUNTA(R[2]C[-2]:R[4999]C[-2])"
j = Range("K1").Value + 2
i = 3
AppTot = 0
PremTot = 0
UWATot = 0
For i = 3 To j
Cells(i, 8).Value = i - 2
Cells(i, 12).FormulaR1C1 = "=COUNTIF(R3C4:R5000C4,RC[-3])"
**AppTot = AppTot + Cells(i, 10)
PremTot = PremTot + Cells(i, 11)
UWATot = UWATot + Cells(i, 12)**
Next i
Range(Cells(3, 8), Cells(j, 8)).Select
With Selection
.HorizontalAlignment = xlRight
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Columns.AutoFit
Selection.Font.Bold = True
Range("K1").Select
Selection.ClearContents
Range("A1").Select
Cells(j + 1, 9).FormulaR1C1 = "Totals:"
Selection.Font.Bold = True
Cells(j + 1, 10).Value = AppTot
Cells(j + 1, 11).Value = PremTot
Cells(j + 1, 12).Value = UWATot