excel vba在单元格中选择第二个最后一个字符 [英] excel vba select second to last character in a cell

查看:1033
本文介绍了excel vba在单元格中选择第二个最后一个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以为这很简单,但是找不到解决方案!
我正在写一个宏,在单元格中的现有文本之后插入一个红色的刻度(或向下箭头)。

  ActiveCell.FormulaR1C1 = ActiveCell& P

P需要格式化为粗体,红色和Wingdings 2.它需要一个空格如果以后添加文本,则会在以后添加。



如果在文本之前没有问题:

 使用ActiveCell.Characters(开始:= 2,长度= 1).Font 

当单元格中第二个到最后一个字符时,如何选择它?



(或任何其他方式来实现?) / p>

谢谢!

解决方案

尝试这个:

 使用ActiveCell.Characters(ActiveCell.Characters.count  -  1,1).Font 
.name =Wingdings 2
.Bold = True
结束


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!

解决方案

Try this:

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

这篇关于excel vba在单元格中选择第二个最后一个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆