Function ReplaceList(sourceList As Variant, fromList As Variant) As Variant ' similar to @replace in formula language ' sourceList - source list ' fromList - from list containing values to remove from sourceList ' return result back in ReplaceList Dim x As Long ' counter for fromList Dim y As Long ' counter for sourceList Dim xstr As String ' string value of x in fromList On Error Goto ErrorHandler ' go through all the values in fromList For x=0 To Ubound(fromList) xstr = fromList(x) ' see if x in fromList is in sourceList and remove if so For y =0 To Ubound(sourceList) If sourceList(y) = xstr Then ' remove that value from the source list (we will fulltrim later) sourceList(y)="" End If Next y sourceList=Fulltrim(sourceList) Next x ' return result replaceList = sourceList Exit Function ErrorHandler: Dim errormsg As String ' error msg to return to user errormsg = "
" & "ReplaceList Error: " & "Info: " & Str(Err) & ": " & Error$ & " on line: " & Cstr(Erl) Print errormsg End Function