type mismatch error in Benford's law macro

S

Sody

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?
 
K

K Dales

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))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top