【问题标题】:Merging text from different cells and keeping the format合并来自不同单元格的文本并保持格式
【发布时间】:2021-04-14 17:39:26
【问题描述】:

是否可以将信息从多个单元格复制到一个单元格并保留格式?例如,我有 A1=Hello (Green, bold font), A2, World (red font)

想要 B2=Hello World(不同颜色的单词)。

在 Google 表格中寻找解决方案,但作为替代方案,Excel 也可以工作

【问题讨论】:

    标签: vba google-apps-script


    【解决方案1】:

    例如,我的 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
    

    【讨论】:

      【解决方案2】:

      谢谢银行家。

      我需要的解决方案有点不同 - 字符数是可变的,我纯粹需要从原始单元格中复制格式。

      给出一个大图 - 有一个大约 8 列的表格,每列都有自己的颜色,但单元格中的字符数会有所不同。目标是创建一个包含来自指定行的信息的句子……但是句子中每个单词的格式需要与原始表中的格式相同。

      可能会使用此解决方案,但需要从原始单元格中识别每种颜色的字符数并将其作为变量放入代码中

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-06-17
        • 1970-01-01
        • 2021-09-20
        • 1970-01-01
        • 1970-01-01
        • 2013-09-26
        • 2018-01-08
        • 1970-01-01
        相关资源
        最近更新 更多