Cleaning up data -- any way to globally fix this??
The Moose wrote:
<BFlamingo Cookie Jar</B<BRMade of porcelain and measures Body 6" x
7" With Lid and tail 10"x11"
gets converted to this in either a CSV worksheet or an XLS worksheet:
Flamingo Cookie JarMade of porcelain and measures Body 6" x 7" With
Lid and tail 10"x11"
The <BR gets eliminated between the heading and the description which
causes two words to be 'stuck' together.
Spell checking finds them -- but, there are thousands of these -- is
there any way to fix this automatically?? (I don't have access to the
source data.)
Thanks.
Barb
Hi Barb,
this macro checks each cell of the selected range for instances of a
lowercase character followed by an uppercase character without an
intervening space. When such an instance is found a space is
inserted...
Public Sub AddSpc()
Application.ScreenUpdating = False
Dim rngAddSpace As Range
Dim rngCell As Range
Set rngAddSpace = Application.InputBox( _
prompt:="Select Cells with missing space", _
Title:="Add Missing Space", _
Default:=Selection.Address, _
Type:=8)
Dim strArray() As String
Dim I As Long
Dim Character As Long
For Each rngCell In rngAddSpace
strArray = Split(rngCell, " ")
For I = 0 To UBound(strArray)
For Character = 1 To Len(strArray(I)) - 1
If UCase(Mid(strArray(I), Character, 1)) _
< Mid(strArray(I), Character, 1) _
And UCase(Mid(strArray(I), Character + 1, 1)) _
= Mid(strArray(I), Character + 1, 1) Then
strArray(I) = Left(strArray(I), Character) _
& Space(1) _
& Mid(strArray(I), Character + 1, 255)
End If
Next Character
Next I
rngCell.Value = Join(strArray)
Next rngCell
End Sub
Try it out on a copy of your data first just in case it doesn't do what
you want.
Ken Johnson
|