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 19, 2022MVP
Does your colleague have a Mac? The macro that I posted will only work in the desktop version of Excel for Windows.
alex2476
Mar 19, 2022Copper Contributor
YES she does have a Mac! Anyway to get around this?
- HansVogelaarMar 19, 2022MVP
This version should work on both Mac and Windows:
Function ExtractNum(s As String) As String Dim d As Collection Dim a() As String Dim n As String Dim i As Long Dim r As String Set d = New Collection a = Split(s, ", ") For i = 0 To UBound(a) n = Split(a(i), ".")(0) On Error Resume Next d.Add Item:=n, Key:=n On Error GoTo 0 Next i For i = 1 To d.Count r = r & ", " & d(i) Next i If r <> "" Then ExtractNum = Mid(r, 3) End If End Function- alex2476Mar 20, 2022Copper ContributorThis seems to work very well across both Platforms!
Big Thanks to you Hans!