user1606185
0
Q:

excel vba clean non breaking space

'VBA function to clean data from range and return an array. This
'function does NOT use loops:

Function CleanMAX(r As Range)
    CleanMAX = Replace("trim(clean(substitute(|,char(160),"" "")))", "|", r.Address)
    If r.Cells.Count > 1 Then CleanMAX = "index(" & CleanMAX & ",)"
    CleanMAX = Evaluate(CleanMAX)
End Function

'--------------------------------------------------------------------

'Clean the value and returns a SCALAR, not an arry:
v = CleanMAX([a1])

'Clean every value and create a 2D array with 10 rows and 26 columns:
v = CleanMAX([a1:z10])

'--------------------------------------------------------------------

'Note:  this function also removes non-breaking space (ASCII 160).

2

New to Communities?

Join the community