Hello, I'm using excel and hit a rock. The problem is that a cell that I need/want to change it's contents, has some mixed formatting (colours, bold and italic). Using the replace method, all formatting disappears. Next, I've tried Characters Delete and Insert methods. These do either nothing (Delete) or replace text.
I have a cell A1 with contents "aap noot mies" where "mies" is red, bold and italic.
When I run this VBA script:
Sub test_Click() Dim txt As String txt = "vuur boom roos" & vbNewLine Sheet1.Cells(1, 1).Characters(5).Insert txt End Sub
"mies" gets replaced with "vuur boom roos" followed by a NewLine. And I expected:
aap noot vuur boom roos mies
And "mies" stays red, bold and italic.
See attachments. excel-vba-orig.png is the starting point, excel-vba-changed.png is what I get and excel-vba-expected.png is what I expected. And test.xlsm is a simple test excel file.