-
-
Notifications
You must be signed in to change notification settings - Fork 0
CleanString
Rodrigo Celso de Lima Porto edited this page Jan 14, 2026
·
3 revisions
Cleans a string by removing or replacing special and control characters with spaces.
CleanString( _
myString As String, _
Optional ReplaceBySpace As Boolean = True, _
Optional ConvertNonBreakingSpace As Boolean = True _
) As String-
myString: The input string to be cleaned -
ReplaceBySpace: (optional) Boolean flag that determines if special characters should be replaced by spaces-
True(Default): Replaces special characters with spaces -
False: Removes special characters without replacement
-
-
ConvertNonBreakingSpace: (optional) Boolean flag to handle non-breaking spaces-
True(Default): Converts non-breaking spaces (ASCII 160) to regular spaces -
False: Leaves non-breaking spaces unchanged
-
Returns the cleaned string with special characters either removed or replaced by spaces.
- Removes ASCII control characters (0-31)
- Handles special characters like ASCII 127, 129, 141, 143, 144, and 157
- Converts non-breaking spaces to regular spaces (when enabled)
- Trims leading and trailing spaces from the final result
- Preserves all other printable characters
Dim cleanedStr As String
' Replace special characters with spaces
cleanedStr = CleanString("Hello" & Chr(0) & "World")
Debug.Print cleanedStr ' Result: "Hello World"
' Remove special characters
cleanedStr = CleanString("Hello" & Chr(0) & "World", False)
Debug.Print cleanedStr ' Result: "HelloWorld"
' Keep non-breaking spaces
cleanedStr = CleanString("Hello" & Chr(160) & "World", True, False)
Debug.Print cleanedStr ' Result: Original string unchanged- Binary.Unzip πβοΈ
- DateTime.ToUnixTime πβοΈ
- Decision.EntropyWeights πβοΈ
- Decision.TOPSIS πβοΈ
- List.Correlation πβοΈ
- List.Intercept πβοΈ
- List.Outliers πβοΈ
- List.PopulationStdDev πβοΈ
- List.Primes πβοΈ
- List.Rank πβοΈ
- List.Slope πβοΈ
- List.Variance πβοΈ
- List.WeightedAverage πβοΈ
- Number.FromRoman πβοΈ
- Number.IsInteger πβοΈ
- Number.IsPrime πβοΈ
- Number.ToRoman πβοΈ
- Statistical.NormDist πβοΈ
- Statistical.NormInv πβοΈ
- Table.AddColumnFromList πβοΈ
- Table.CorrelationMatrix πβοΈ
- Table.NormalizeColumnNames πβοΈ
- Table.NormalizeTextColumns πβοΈ
- Table.RemoveBlankColumns πβοΈ
- Table.TransposeCorrectly πβοΈ
- Text.CountChar πβοΈ
- Text.ExtractNumbers πβοΈ
- Text.HtmlToPlainText πβοΈ
- Text.RegexExtract πβοΈ
- Text.RegexReplace πβοΈ
- Text.RegexSplit πβοΈ
- Text.RegexTest πβοΈ
- Text.RemoveAccents πβοΈ
- Text.RemoveDoubleSpaces πβοΈ
- Text.RemoveLetters πβοΈ
- Text.RemoveNumerals πβοΈ
- Text.RemovePunctuations πβοΈ
- Text.RemoveStopwords πβοΈ
- Text.RemoveWeirdChars πβοΈ
- AreArraysEquals πβοΈ
- AutoFillFormulas πβοΈ
- CleanString πβοΈ
- DisableRefreshAll πβοΈ
- EnableRefreshAll πβοΈ
- FileExists πβοΈ
- FileNameIsValid πβοΈ
- GetAllFileNames πβοΈ
- GetLetters πβοΈ
- GetMonthNumberFromName πβοΈ
- GetStringBetween πβοΈ
- GetStringWithSubstringInArray πβοΈ
- GetTableColumnNames πβοΈ
- IsAllTrue πβοΈ
- IsInArray πβοΈ
- ListObjectExists πβοΈ
- PreviousMonthNumber πβοΈ
- RangeHasAnyFormula πβοΈ
- RangeHasConstantValues πβοΈ
- RangeIsHidden πβοΈ
- RangeToHtml πβοΈ
- SendEmail πβοΈ
- SetQueryFormula πβοΈ
- StringContains πβοΈ
- StringEndsWith πβοΈ
- StringStartsWith πβοΈ
- SubstringIsInArray πβοΈ
- Summation πβοΈ
- TableHasQuery πβοΈ
- WorksheetHasListObject πβοΈ