Save the three function below into a standard module as save module as ModFractions
' Will convert a fraction, such as 12 3/4 to
' it's decimal equivalent, 12.75
'Then it divides it by 10
Code:
Public Function ConvertFraction(strGetNumber As String) As Double
Dim dblFraction As Double
Dim intPosition As Integer
Dim strTop As String
Dim strBottom As String
Dim dblWhole As Double
Dim strFraction As String
On Error GoTo Err_Convert
intPosition = InStr(strGetNumber, "/")
If intPosition = 0 Then
ConvertFraction = strGetNumber ' Not a whole number
Exit Function
End If
intPosition = InStr(strGetNumber, " ")
If intPosition > 0 Then
dblWhole = Val(Left(strGetNumber, intPosition - 1))
Else
dblWhole = 0
End If
strFraction = Mid(strGetNumber, intPosition + 1)
intPosition = InStr(strFraction, "/")
strTop = Left(strFraction, intPosition - 1)
strBottom = Mid(strFraction, intPosition + 1)
dblFraction = Val(strTop) / Val(strBottom)
ConvertFraction = Round(Round(dblWhole + dblFraction, 4)/10)
Exit_Function:
Exit Function
Err_Convert:
'MsgBox "Error #: " & Err.Number & " " & Err.Description, vbInformation
Resume Exit_Function
End Function
Determines the Column heading gouper
Code:
Public Function FractionGrouper(Fraction As Double) As String
Select Case Fraction
Case Is < 0.0001: FractionGrouper = "E"
Case 0.0001 To 0.001: FractionGrouper = "D"
Case 0.001 To 0.01: FractionGrouper = "C"
Case 0.01 To 0.1: FractionGrouper = "B"
Case 0.1 To 1: FractionGrouper = "A"
Case Else: FractionGrouper = "Z"
End Select
End Function
Determines the Row Groupper
Code:
Public Function PriceGrouper(AnyValue As Double) As String
Select Case AnyValue
Case Is > 10000000: PriceGoupter = "I"
Case 1000000 To 9999999: PriceGrouper = "II"
Case 100000 To 999999: PriceGrouper = "III"
Case Else: PriceGrouper = "IV"
End Select
End Function
Crosstab Query:
Row heading : PriceGrouper([UMRC])
Column heading : FractionGrouper(ConvertFraction([UMRP]))
Group By Row heading
This should give you the output you need to enable you export to Excel
David