Sorry not at a computer just now and while i have ideas, i like to test what i post. I will try to get back to you shortly... Tomorrow morning at the latest
Sorry not at a computer just now and while i have ideas, i like to test what i post. I will try to get back to you shortly... Tomorrow morning at the latest
Please help by:
Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know
There are 10 kinds of people in this world... those who understand binary, and those who don't.
You say sometimes the list is itemized either by double spaces or by numbers.... are the ONLY double spaces in a cell there to divide items? If so, then we can use the same principle to split up those cells in a new loop, I don't know if you want bullets replacing the double spaces to standardize your list? I'm assuming yes... but I'll put in red the pieces to take out if you don't want the bullet put into those:
Please check out the forum rules, it will show you how to add code tags when you paste code so that things are easier to read.![]()
Sub CleanSpacesA() Dim sht As Worksheet Dim original_text() As String Dim new_text As String Dim lr As Long Dim i As Long Dim j As Long Set sht = Worksheets("Sheet1") lr = sht.Range("A" & Rows.Count).End(xlUp).Row 'replace with correct column i = 1 For i = 1 To lr With Range("A" & i) 'replace with correct column .Value = WorksheetFunction.Trim(.Value) End With Next i 'separate bullet items into separate rows For i = lr To 2 Step -1 new_text = vbNullString original_text = Split(sht.Range("A" & i).Value, "•") 'replace with correct column For j = 1 To UBound(original_text) If j < UBound(original_text) Then new_text = new_text & "•" & original_text(j) & vbCrLf Else new_text = new_text & "•" & original_text(j) End If Next j If UBound(original_text) > 0 Then sht.Range("A" & i).Value = new_text 'replace with correct column Next i 'separate double space items into separate rows For i = lr To 2 Step -1 new_text = vbNullString original_text = Split(sht.Range("A" & i).Value, " ") 'replace with correct column For j = 1 To UBound(original_text) If j < UBound(original_text) Then new_text = new_text & "•" & original_text(j) & vbCrLf Else new_text = new_text & "•" & original_text(j) End If Next j If UBound(original_text) > 0 Then sht.Range("A" & i).Value = new_text 'replace with correct column Next i Set sht = Nothing End Sub
As far as numbers goes, that is a problem, since it is very hard for code to know which numbers are there for the listing of items, and which numbers are part of your valid text. Unless you can guarantee that numbers are ONLY ever used to separate list items and there are NO numbers at all that are part of normal text. Is there any extra criteria we can use to identify those?
Last edited by Arkadi; 06-10-2016 at 09:20 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks