ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   type mismatch error in Benford's law macro (https://www.excelbanter.com/excel-programming/362360-type-mismatch-error-benfords-law-macro.html)

Sody

type mismatch error in Benford's law macro
 
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 Dales[_2_]

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?



All times are GMT +1. The time now is 03:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com