+ Reply to Thread
Results 1 to 16 of 16

Fixing Bullet Lists with VBA Macro

Hybrid View

  1. #1
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059
    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.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Fixing Bullet Lists with VBA Macro

    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:

    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
    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.

    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Fixing Update Macro
    By bgrish3 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-31-2016, 12:37 PM
  2. Macro fixing background color after using cf
    By Jhon Mustofa in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-17-2014, 10:06 AM
  3. Bullet point and sub bullet points with numbers
    By trumpetman in forum Word Formatting & General
    Replies: 3
    Last Post: 12-17-2012, 12:23 PM
  4. Help please fixing a macro
    By tyleromaha in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-09-2012, 12:07 PM
  5. Need help fixing macro
    By Kb24 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-23-2009, 03:19 AM
  6. [SOLVED] Fixing SSN's with a macro
    By Bruce Martin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-18-2005, 02:05 AM
  7. [SOLVED] Fixing a macro
    By Tim Dolan in forum Excel General
    Replies: 13
    Last Post: 01-18-2005, 11:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1