excel vba:使字符串粗体的一部分 [英] excel vba: make part of string bold

查看:247
本文介绍了excel vba:使字符串粗体的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  name / A / date 
name / B /日期
名称/ C /日期

单元格内容显示在同一单元格的多行中。我只想为所有条目只加bold。我记录了一个宏,我认为解决方案必须是这样的:

  ActiveCell.FormulaR1C1 =name / A / date &安培; Chr(10)& name / B / date& Chr(10)& name / C / date
使用ActiveCell.Characters(开始:= 25,长度= 4).Font
.FontStyle =Bold
End with

我不知道的是如何获取每个条目的起始值和长度。任何人都有想法?

解决方案

现在有:

  lngPos = InStr(ActiveCell.Value,/)
使用ActiveCell.Characters(开始:= 1,长度:= lngPos - 1).Font
.FontStyle = Bold
结束


I have excel cells which contain entries like this:

name/A/date
name/B/date
name/C/date

Cell content is displayed on multiple lines in the same cell. I would like to make only "name" bold for all entries. I recorded a macro and I think the solution must be something like this:

ActiveCell.FormulaR1C1 = "name/A/date" & Chr(10) & "name/B/date" & Chr(10) & "name/C/date"
With ActiveCell.Characters(Start:=25, Length:=4).Font
    .FontStyle = "Bold"
End With

What I don't know is how to get the start value and the length of each entry. Anyone got an idea?

解决方案

Have it now:

lngPos = InStr(ActiveCell.Value, "/")
With ActiveCell.Characters(Start:=1, Length:=lngPos - 1).Font
    .FontStyle = "Bold"
End With

这篇关于excel vba:使字符串粗体的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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