I am attempting to select a cell filled with text and split/parse the text onto individual rows in a new workbook while maintaining the source font format (i.e. bold text).
In the code below I am attempting to perform my split on the row cell value, which I know will remove my formatting and bold font. This works if my bold text is in a cell by itself, but when I have bold and non-bold text in the same cell, my entire output ends up bolded. If I omit the bold font change, then my cell is missing the bold font.
Is there a way to perform a split while maintaining the cell format?
Sub Macro1()
Dim InputData As Range
Dim arr() As String
Dim NewBook As Workbook
Dim shnew As Worksheet
counter = 0
counter2 = 0
Boxtitle = " Find and Bold"""
Set InputData = Application.Selection.Range("A1")
Set InputData = Application.InputBox("Select cell Range: ", Boxtitle, InputData.Address, Type:=8)
'Create new workbook instance
Set NewBook = Workbooks.Add
Set shnew = NewBook.Worksheets.Add
' Loop through range and split on delimitter and add to array
For Each x In InputData.Rows
If InputData.Cells(1 + counter, 1).Font.Bold = False Then
arr = Split(InputData.Cells(1 + counter, 1), ". ")
counter = counter + 1
For Each i In arr
shnew.Cells(1 + counter2, 1) = i
counter2 = counter2 + 1
Next
Else
arr = Split(InputData.Cells(1 + counter, 1), ". ")
counter = counter + 1
For Each i In arr
shnew.Cells(1 + counter2, 1).Font.Bold = True
shnew.Cells(1 + counter2, 1) = i
counter2 = counter2 + 1
Next
End If
Next
End Sub