Partial Bold Logic of a Cell in VBA

Copper Contributor

qazzzlyt_0-1715260039729.png

In above picture, the first character of the cell is bold, and the second is not. However, in aa, when I select the cell, the cell is not shown as bold; in bb, the cell is shown as bold.

 

How to reproduce aa in VBA? When I use Characters(,).Font, it always give me results like bb.

 

The purpose is, I need to manually input some text after the 2 characters. In bb, my manual input become bold, but I do not want this.

 

Thanks in advance.

1 Reply

@qazzzlyt 

The following is just a guess.

Excel has a fairly complicated way of storing cell contents and formatting. It looks like it matters how you apply the format.

  • If you select a cell, apply Bold by clicking the B button or pressing Ctrl+B, then start typing, you'll see B highlighted even after un-bolding characters after the first one.
  • If you select a cell, start typing, and only then make the first character(s) bold, B will not be highlighted when you select the cell.

However, as you have found, it does not work this way in VBA. Regardless of how you populate a cell and format its characters, B will be highlighted if the first character is bold.