简体   繁体   中英

excel vba select second to last character in a cell

I thought this would be simple but can't find the solution anywhere! I am writing a macro to insert a red tick (or down arrow) after the existing text in a cell.

 ActiveCell.FormulaR1C1 = ActiveCell & " P "

The P needs to be formatted bold, red and Wingdings 2. It needs a space after it in case text is added at the end in the future.

No problem if it is before the text:

With ActiveCell.Characters(Start:=2, length:=1).Font

How can I select it when it is the second to last character in the cell?

(Or is there any other way to achieve this?)

Try this:

With ActiveCell.Characters(ActiveCell.Characters.count - 1, 1).Font
  .name = "Wingdings 2"
  .Bold = True
End With

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM