I am trying to find the minimum value on a given range. However, my range starts with a character and the row is formatted as Text. I worked around it by using the Val function but I was wondering if there is an easier way to find the minimum value. Range C21:C25 are blank in this current range so i gave them a value of 1000. I know my range values are less than 1000.
Thanks for your time and help.
Code:
Sub Macro2()
'
' Macro1 Macro
'
'
Dim Rng As Range
Dim X1 As Double, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15
X1 = Right(Range("C11").Value, 2)
If X1 = NullString Then
X1 = "1000"
Else
Val (X1)
End If
X2 = Right(Range("C12").Value, 2)
If X2 = NullString Then
X2 = "1000"
Else
Val (X2)
End If
X3 = Right(Range("C13").Value, 2)
If X3 = NullString Then
X3 = "1000"
Else
Val (X3)
End If
X4 = Right(Range("C14").Value, 2)
If X4 = NullString Then
X4 = "1000"
Else
Val (X4)
End If
X5 = Right(Range("C15").Value, 2)
If X5 = NullString Then
X5 = "1000"
Else
Val (X5)
End If
X6 = Right(Range("C16").Value, 2)
If X6 = NullString Then
X6 = "1000"
Else
Val (X6)
End If
X7 = Right(Range("C17").Value, 2)
If X7 = NullString Then
X7 = "1000"
Else
Val (X7)
End If
X8 = Right(Range("C18").Value, 2)
If X8 = NullString Then
X8 = "1000"
Else
Val (X8)
End If
X9 = Right(Range("C19").Value, 2)
If X9 = NullString Then
X9 = "1000"
Else
Val (X9)
End If
X10 = Right(Range("C20").Value, 2)
If X10 = NullString Then
X10 = "1000"
Else
Val (X10)
End If
X11 = Right(Range("C21").Value, 2)
If X11 = NullString Then
X11 = "1000"
Else
Val (X11)
End If
X12 = Right(Range("C22").Value, 2)
If X12 = NullString Then
X12 = "1000"
Else
Val (X12)
End If
X13 = Right(Range("C23").Value, 2)
If X13 = NullString Then
X13 = "1000"
Else
Val (X13)
End If
X14 = Right(Range("C24").Value, 2)
If X14 = NullString Then
X14 = "1000"
Else
Val (X14)
End If
X15 = Right(Range("C25").Value, 2)
If X15 = NullString Then
X15 = "1000"
Else
Val (X15)
End If
On Error Resume Next
dblMin = Application.WorksheetFunction.Min(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15)
MsgBox dblMin
End Sub
Thanks for your time and help.