I
I Maycotte
Hello everyone,
I am having trouble debugging the following function
Code
-------------------
Function RATELOOKUP(ByVal strProdName As String, ByVal strPremType As String, ByVal strTrailOption As String, _
ByVal strCompSched As String, ByVal nPremBand As Integer, ByVal strPremRange As Variant, _
ByVal strAgeBand As String)
Dim wsAutoFilter as Worksheet
Dim rgeProdName
Dim rgePremType
Dim rgeTrailOption
Dim rgeCompSched
Dim rgePremBand
Dim rgePremRange
Dim rgeAgeBand
Dim rgeSelected
Dim CellValue
Set wsAutoFilter = Worksheets("Autofilter")
With wsAutoFilter
rgeProdName = .Range("ProdName") 'A:A
rgePremType = .Range("PremType") 'B:B
rgeTrailOption = .Range("TrailOption") 'C:C
rgeCompSched = .Range("CompSched") 'D
rgePremBand = .Range("PremBand") 'E:E
rgePremRange = .Range("PremRange") 'F:F
rgeAgeBand = .Range("AgeBand") 'G:G
rgeSelected = .Range("Selected") 'H:H
End With
With Application.WorksheetFunction
CellValue = .Index(rgeSelected, .Match(strProdName & strPremType & strTrailOption & _
strCompSched & nPremBand & strPremRange & strAgeBand, rgeProdName & rgePremType & _
rgeTrailOption & rgeCompSched & rgePremBand & rgePremRange & rgeAgeBand, 0))
End With
'CellValue = "=INDEX(" & rgeSelected & ",MATCH(" & strProdName & "&" & strPremType & "&" &
' strTrailOption & "&" & strCompSched & "&" & nPremBand & "&" & strPremRange & "&" & _
' strAgeBand & "," & rgeProdName & "&" & rgePremType & "&" & rgeTrailOption & "&" & _
' rgeCompSched & "&" & rgePremBand & "&" & rgePremRange & "&" & rgeAgeBand & ",0))"
RATELOOKUP = CellValue
End Functio
-------------------
I get the error: "Type Mismatch" on the CellValue
.Index(rgeSelected... line, and I don't know what to do to fix it. I
you could help degug, I'd appreciate it. Thank you
I am having trouble debugging the following function
Code
-------------------
Function RATELOOKUP(ByVal strProdName As String, ByVal strPremType As String, ByVal strTrailOption As String, _
ByVal strCompSched As String, ByVal nPremBand As Integer, ByVal strPremRange As Variant, _
ByVal strAgeBand As String)
Dim wsAutoFilter as Worksheet
Dim rgeProdName
Dim rgePremType
Dim rgeTrailOption
Dim rgeCompSched
Dim rgePremBand
Dim rgePremRange
Dim rgeAgeBand
Dim rgeSelected
Dim CellValue
Set wsAutoFilter = Worksheets("Autofilter")
With wsAutoFilter
rgeProdName = .Range("ProdName") 'A:A
rgePremType = .Range("PremType") 'B:B
rgeTrailOption = .Range("TrailOption") 'C:C
rgeCompSched = .Range("CompSched") 'D

rgePremBand = .Range("PremBand") 'E:E
rgePremRange = .Range("PremRange") 'F:F
rgeAgeBand = .Range("AgeBand") 'G:G
rgeSelected = .Range("Selected") 'H:H
End With
With Application.WorksheetFunction
CellValue = .Index(rgeSelected, .Match(strProdName & strPremType & strTrailOption & _
strCompSched & nPremBand & strPremRange & strAgeBand, rgeProdName & rgePremType & _
rgeTrailOption & rgeCompSched & rgePremBand & rgePremRange & rgeAgeBand, 0))
End With
'CellValue = "=INDEX(" & rgeSelected & ",MATCH(" & strProdName & "&" & strPremType & "&" &
' strTrailOption & "&" & strCompSched & "&" & nPremBand & "&" & strPremRange & "&" & _
' strAgeBand & "," & rgeProdName & "&" & rgePremType & "&" & rgeTrailOption & "&" & _
' rgeCompSched & "&" & rgePremBand & "&" & rgePremRange & "&" & rgeAgeBand & ",0))"
RATELOOKUP = CellValue
End Functio
-------------------
I get the error: "Type Mismatch" on the CellValue
.Index(rgeSelected... line, and I don't know what to do to fix it. I
you could help degug, I'd appreciate it. Thank you