For example: 1001001 or 01101 or 11110000 ...

In need a user defined formula in cell B1 that will display the locations of the 1's in the text string, reading from

__right to left__with 0 being the first location on the right.

For example if I have this text string in cell A1: 1001111

Cell B1 should display the following: 0, 1, 2, 3, 6

I got this from member "HotPepper" (thanks for the help)

formula in cell B1:

--------------------------------------------------------------------------------

=binpos(A1,1) to find the 1s

or

=binpos(A1,0) to find the 0s

if the second number is not provided, it will find the 0s.

code:

--------------------------------------------------------------------------------

Public Function BinPos(s As String, Optional num As Integer)

If num <> 0 Then num = 1

Dim x As Integer, b As String

For x = 1 To Len(s)

If Mid(s, x, 1) = num Then b = b & x-1 & " "

Next x

BinPos = Replace(Trim(b), " ", ",")

End Function

This code got me close but read from left to right.