Solved in Excel PowerQuery Add-in - Longer but much easier to follow especially with the help of the Query Editor.

My solution also gives the Luhn digit if given an input of 14 digits and throws an easy to comprehend error message if given an invalid input. See demo video here

Full query function text:

(Input as any) =>

let

TextControl = try Number.ToText(Input) otherwise Input,

ListChars = Text.ToList(TextControl),

CheckFigs = List.FirstN(ListChars, 14),

ControlChar = if List.Count(ListChars) = 15 then ListChars{14} else null,

EveryOther = List.Alternate(CheckFigs, 1, 1, 0),

NonDoubled = List.Difference(CheckFigs, EveryOther),

DoubledEveryOther = List.Transform(EveryOther, (_) => Number.ToText(List.Product({Number.From (_), 2}))),

SplitoutDigits = List.Transform(DoubledEveryOther, (_) => Text.ToList(_)),

CombineSubDigits = List.Combine(SplitoutDigits),

CombineCheckFigs = List.Transform(List.Combine({CombineSubDigits, NonDoubled}), (_) => Number.From(_)),

SumAllDigits = List.Sum(CombineCheckFigs),

IMEIResult = 10 - Number.Mod(SumAllDigits, 10),

Output = if List.Count(ListChars) = 14

then IMEIResult

else if (List.Count(ListChars) <> 15)

then Error.Record("Required Numeric Input of Length 14 or 15.", "Error in Input")

else IMEIResult = Number.From(ControlChar)

in

Output