vba - 合并来自不同单元格的文本并保持格式
问题描述
是否可以将信息从多个单元格复制到一个单元格并保持格式?例如,我有 A1=Hello (Green, bold font), A2, World (red font)
想要 B2=Hello World(用不同颜色的单词)。
在 Google 表格中寻找解决方案,但作为替代方案,Excel 也可以使用
解决方案
例如,我的 activecell 有单词“bankeris”,所以我将前 3 个字母设为一种颜色,另外 3 个字母设为另一种颜色。此代码是通过“宏录制”。所以复制/粘贴也会这样做。
With ActiveCell.Characters(Start:=1, Length:=3).Font
.Name = "Calibri"
.FontStyle = "Regular"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.Color = -16776961
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
With ActiveCell.Characters(Start:=4, Length:=3).Font
.Name = "Calibri"
.FontStyle = "Regular"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorAccent6
.TintAndShade = -0.249977111117893
.ThemeFont = xlThemeFontMinor
End With
推荐阅读
- c++ - Bad instanition in function that is not itself instantiated. Difference in behaviour between clang and gcc
- qnamaker - QnA Maker Web 应用程序 - 如果未找到结果,则调用 REST API
- spring-boot - 出现错误配置的节点都不可用:在弹性搜索中
- python - 使用 Google 表格触发位于 Google Drive 中的 Python 脚本
- java - C++ 客户端向 Java 服务器发送奇怪的数据
- python - Django中正确的身份验证测试结构
- javascript - Google Cloud Function 不会触发 Stripe 的端点
- python - 如何在数据框中列出路径时使用 pyspark 读取镶木地板文件
- spring-boot - 访问注解中的方法签名变量
- javascript - webpack 生成带有哈希的文件并将其包含在应用程序的某个位置