Help with odd type mismatch error
Tony,
The only thing I can think of is that the textbox isn't numeric, but
contains letters or such. This would throw that error.
You could make sure only numbers and dot input with this code
Private Sub txtLowPercent_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case 48 To 57 'Nos 0 - 9
Exit Sub
Case 32 ' space
Case 46 ' dot
Case Else
KeyAscii = 0
End Select
End Sub
Using worksheetfunctions in VBA is fine, in fact often the best way to avoid
re-inventing the meal.
--
HTH
RP
(remove nothere from the email address if mailing direct)
"George Raft" wrote in message
...
Hi all:
I'm getting a type mismatch with the following code:
WorksheetFunction.Percentile(rngIn.Columns(Indx), _
CDbl(txtLowPercent.Value) / 100#)
rngIn is type Range and already set. txtLowPercent is a textbox on a
userform - this code in part of the userform code.
If I replace the CDbl() by a number like 95.0 then the code works fine. I
thought CDbl() should work in this situation since Percentile expects a
Double.
So, two questions. First, what's the problem here? Second, is there an
Application level function that replaces the worksheet function Percentile
that I should be using use?
I'm working in Excel 97 under Win98.
Thanks Tony (this is a great group - I wish I had something to offer
besides
questions)
|