Link to home
Start Free TrialLog in
Avatar of brothertruffle880
brothertruffle880Flag for United States of America

asked on

Excel VBA - How to detect too-narrow columns

I performed a calcluation in a cell and the calculated result was larger than the cell width, thus, generating a cell filled with #######.

How can VBA detect a too-narrow column and then adjust its width?
ASKER CERTIFIED SOLUTION
Avatar of nand633
nand633

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Norie
Norie

Are you sure it's because the result is to wide for the cell?

It could actually be because the formula returns an error.

Or the cell has been formatting incorrectly.
To detect ### and then change the column width you can try something like

if left(range("d1").Text ,3)="###" then range("D1").EntireColumn.AutoFit