# Benford's law - Generalization to digits beyond the first -- Is there a VBA solution?

#### Juggler_IN

##### Board Regular
I am looking for a VBA led output for 2nd, 3rd, 4th, etc, (Generalization to digits beyond the first).

The refrence link is : Benford's law - Wikipedia

Essentially the formula to code is below the text "And the probability that d (d = 0, 1, ..., 9) is encountered as the n-th (n > 1) digit is"

Thanks

### Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

#### shg

##### MrExcel MVP
To replicate the table,

 A​ B​ C​ D​ E​ F​ G​ H​ I​ J​ K​ L​ 5​ Pos\Digit​ 0​ 1​ 2​ 3​ 4​ 5​ 6​ 7​ 8​ 9​ 6​ 1​ n/a​ 30.10%​ 17.61%​ 12.49%​ 9.69%​ 7.92%​ 6.69%​ 5.80%​ 5.12%​ 4.58%​ C6: =LOG(1 + 1/C\$5) 7​ 2​ 11.97%​ 11.39%​ 10.88%​ 10.43%​ 10.03%​ 9.67%​ 9.34%​ 9.04%​ 8.76%​ 8.50%​ B7: =SUMPRODUCT(LOG(1 + 1/(10*ROW(INDIRECT(10^(\$A7-2) & ":" & 10^(\$A7-1) - 1)) + B\$5))) 8​ 3​ 10.18%​ 10.14%​ 10.10%​ 10.06%​ 10.02%​ 9.98%​ 9.94%​ 9.90%​ 9.86%​ 9.83%​ 9​ 4​ 10.02%​ 10.01%​ 10.01%​ 10.01%​ 10.00%​ 10.00%​ 9.99%​ 9.99%​ 9.99%​ 9.98%​ 10​ 5​ 10.00%​ 10.00%​ 10.00%​ 10.00%​ 10.00%​ 10.00%​ 10.00%​ 10.00%​ 10.00%​ 10.00%​

Last edited:

#### Juggler_IN

##### Board Regular
@shg, Thanks. This meets the requirement.

You're welcome.

1,102,777
Messages
5,488,784
Members
407,658
Latest member
Arias610

### This Week's Hot Topics

• Timer in VBA - Stop, Start, Pause and Reset
[CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
• how to updates multiple rows in muliselect listbox
Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
• Delete Row from Table
I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
• Assigning to a variable
I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
• Way to verify information
Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
• Active Cell Address – Inactive Sheet
How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...