andreascostas
Board Regular
- Joined
- Jan 11, 2011
- Messages
- 150
How do I tweak this UDF further to get it to give me the output I need
Function Decompose(ByVal Number As String) As String
Dim X As Long
Number = Replace(Number, ",", "")
If Number = 0 Then
Decompose = "0 ones"
Else
For X = Len(Number) To 1 Step -1
If Mid(Number, X, 1) Then Decompose = Mid(Number, X, 1) & Choose(Len(Number) - X + 1, " x 1)", " x 10)", " x 100)", " x 1,000)", " x 10,000)", " x 100,000)") & " + " & Decompose
Next
Decompose = Left(Decompose, Len(Decompose) - 3)
End If
End Function
The UDF as is gives me the following:
In Cell A1: 96,183 output in B1: 9 x 10,000) + 6 x 1,000) + 1 x 100) + 8 x 10) + 3 x 1)
I am missing the opening parenthesis “(“ for each set of numbers. I want it to show this in B1:
(9 x 10,000) + (6 x 1,000) + (1 x 100) + (8 x 10) +(3 x 1)…….A member gave me this UDF to accomplish
A different output. I played around with it to create an additional worksheet for my students,
But I am stuck. I can’t figure out where to put the “(“ to make it work.
Function Decompose(ByVal Number As String) As String
Dim X As Long
Number = Replace(Number, ",", "")
If Number = 0 Then
Decompose = "0 ones"
Else
For X = Len(Number) To 1 Step -1
If Mid(Number, X, 1) Then Decompose = Mid(Number, X, 1) & Choose(Len(Number) - X + 1, " x 1)", " x 10)", " x 100)", " x 1,000)", " x 10,000)", " x 100,000)") & " + " & Decompose
Next
Decompose = Left(Decompose, Len(Decompose) - 3)
End If
End Function
The UDF as is gives me the following:
In Cell A1: 96,183 output in B1: 9 x 10,000) + 6 x 1,000) + 1 x 100) + 8 x 10) + 3 x 1)
I am missing the opening parenthesis “(“ for each set of numbers. I want it to show this in B1:
(9 x 10,000) + (6 x 1,000) + (1 x 100) + (8 x 10) +(3 x 1)…….A member gave me this UDF to accomplish
A different output. I played around with it to create an additional worksheet for my students,
But I am stuck. I can’t figure out where to put the “(“ to make it work.