#### Southall_Legend

##### New Member

- Joined
- Mar 31, 2017

- Messages
- 2

First time poster, and VBA newbie here. I've been trawling the internet and racking my brains to try to solve my problem but haven't got anywhere, so thought I'd register on here to see if anyone can help...

The issue I have is that I'm trying to analyse a formula and I want to be able to count the number of cell references and fixed values in that formula, whilst counting ranges as one. FWIW I'm doing this to analyse the complexity of a formula.

I did think that counting precedents would do this for me, but this count's the number of direct precedents in a range (aka A1:C1 gives "three", whereas I want "one"), and also doesn't work with precedents on a different sheet

So a quick few examples:

Formula | # of cell refs | |

=A1+B1 | 2 | |

=SUM(A1:B1) | 1 | |

=1+SUM(B1:C1) | 2 | |

=IF(A1=1,B1,C1) | 4 |

<tbody>

</tbody>

It's more than possible that there's some obvious way of doing this, staring me in the face; or that some of the information above is incorrect - as I am a newbie. Any help would be greatly appreciated though.

Alternatively, if anyone has a different method of measuring formula complexity, I'd be happy to consider completely different methods.

Thanks