Forum Discussion
alex2476
Mar 18, 2022Copper Contributor
Number Extraction Excel
I have a cell with theses values: 14.19, 14.36, 20.22, 22.23A I would like to have a formula that would extract each of the numbers before the periods and eliminate whatever values are doubl...
HansVogelaar
Mar 18, 2022MVP
Here is a custom VBA function you can use:
Function ExtractNum(s As String) As String
Dim d As Object
Dim a() As String
Dim n As String
Dim i As Long
Set d = CreateObject(Class:="Scripting.Dictionary")
a = Split(s, ", ")
For i = 0 To UBound(a)
n = Split(a(i), ".")(0)
d(n) = Null
Next i
ExtractNum = Join(d.Keys, ", ")
End Function
With a value such as 14.19, 14.36, 20.22, 22.23A in cell A2, the formula
=ExtractNum(A2)
will return 14, 20, 22.
The formula can be filled down if required.
alex2476
Mar 18, 2022Copper Contributor
Thank you so much, I will try this!