View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
K Dales[_2_] K Dales[_2_] is offline
external usenet poster
 
Posts: 1,163
Default type mismatch error in Benford's law macro

The Left function returns a string value; you are at least implicitly
converting your number to string. Make it x = Val(Left(Cells(Colcells,Step),
2))
--
- K Dales


"Sody" wrote:

I am trying to run a Benford's law analysis. I get a run time error 13 -
type mismatch at the following point of the macro:
For Colcells = 1 To Row
x = Left(Cells(Colcells,Step), 2)
If x 9 Then
Arraytwotest(x) = Arraytwotest(x) +1
End If

There is a series of arrays for each of the 9 digits of a number. going from
arrayone to arrayzero. Then there is an array named arraytwotest(10 to 99)
as Integer so that a one digit number does not create an error. This is a
fraud application that published in the Journal of Accountancy in August 2003
with an accompanying download. I downloaded the excel worksheet with macros
and did not make any changes other than import my data file. Any suggestions?