Text to Columns based on formatting

VBAIsHard

New Member
Joined
Jul 15, 2015
Messages
7
Hello very helpful people :)

I registered on this website because i saw you guys are extremely knowledgeable in excel.
I am just beginning VBA and i have encountered a problem i cannot solve.

I basically need text-to-column functionality delimited by formatting (Bold, Italics, normal)

I have done my research and used the search feature and found threads such as
http://www.mrexcel.com/forum/excel-questions/331765-split-cells-bold-text.html

but the results were not working for me.

My data is all in one column and is formatted like this
#. Country Place of Employment Name - email@email.com [Date]


What i want the result to be is each of these in their own column
| #. | Country | Place of Employment | Name | email@email.com | [Date]


I know how to do normal text-to-columns so the last few arnt a problem, but the first ones separated only by formatting is hard and i have no clue what to do.

Thank you in advance!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
I have adapted this solution and i think it's partially working.

This seperates all the bold in A1 and then i change "Bold" to "Italic" and it separates all the italics character. I am almost at my goal.
Credit to stanleydgromjr

Code:
[COLOR=#333333]Option Explicit[/COLOR]<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit;">Sub SplitBold()
' stanleydgromjr, 11/21/2010, EF754022
Dim c As Range, a As Long, BS As String, NS As String
Application.ScreenUpdating = False
For Each c In Range("A1", Range("A" & Rows.Count).End(xlUp))
  BS = "": NS = ""
  For a = 1 To Len(Trim(c)) Step 1
    If c.Characters(a, 1).Text = " " Then
      BS = BS & c.Characters(a, 1).Text
      NS = NS & c.Characters(a, 1).Text
    ElseIf c.Characters(a, 1).Font.FontStyle = "Bold" Then
      BS = BS & c.Characters(a, 1).Text
    ElseIf c.Characters(a, 1).Font.FontStyle <> "Bold" Then
      NS = NS & c.Characters(a, 1).Text
    End If
  Next a
  c.Offset(, 1) = Trim(BS)
  NS = Trim(NS)
  If Left(NS, 1) = Chr(150) Then NS = Right(NS, Len(NS) - 1)
  If Left(NS, 1) = Chr(45) Then NS = Right(NS, Len(NS) - 1)
  c.Offset(, 2) = Trim(NS)
Next c
Application.ScreenUpdating = True </code>[COLOR=#333333]End Sub[/COLOR]
 
Upvote 0
Through the use of the above code in different configurations i have arrived with


| Country | Name of Employment | #. Name - Email@Email.com [Date] |


All in standard format. I think this has made the problem a lot easier. I just need to split up the last column (The first number field is useless), I just need to extract the name and email. They are separated by the "-" but the email could also have a "-" or a "." inside of it
 
Upvote 0
[Update] Text to columns using space delimiter gets me REALLY close to the solution. Only things i cant do is control the people with 1 or 3 words in their name.
What could solve this is using the "-" in between the name and email to separate the two.
 
Upvote 0

Forum statistics

Threads
1,223,719
Messages
6,174,087
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top