Reputation: 163
Trying to figure out how to count the number of leading zeros in an excel cell. The value within the cell can be comprised of both numbers and letters or just numbers or just letters. The column is formatted as a text column.
So far I have been able to use
=MIN(FIND({1,2,3,4,5,6,7,8,9},A1&"123456789"))-1
This gets me all the leading zeros correctly for cells containing only numbers but when it is a combination of both digits and letters it also counts the letters.
eg. 00012 = 3 (correct) 000ab = 5 (should be 3)
Is there a way that I can adapt this formula to not count letters?
Upvotes: 1
Views: 4076
Reputation:
Try looking for the first digit/character that isn't a zero and subtract 1.
=AGGREGATE(15, 7, ROW($1:$9)/(MID(A2, ROW($1:$9), 1)<>"0"), 1)-1
Upvotes: 1