excel vba select second to last character in a cell

柔情痞子 提交于 2019-12-11 09:13:21

问题


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 to select it when it is the second to last character in the cell please?

(Or any other way to achieve this?)

Thanks!


回答1:


Try this:

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


来源:https://stackoverflow.com/questions/45256928/excel-vba-select-second-to-last-character-in-a-cell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!