如何在Excel中只复制特定颜色的文本?

我有一个包含大量文本的大量单元格的工作表。 在任何特定的单元格中,可能会有一些文字显示为红色。 我想删除该文本并将其复制到不同的列。

我有一个VBA函数,通过逐个字符地检查单元格内容来完成这个工作,但是电子表格是相当大的,这个过程变慢了。 有没有更有效的方法来做到这一点?

你的问题有点含糊,但它看起来像你需要你的VBA函数检查每个单元格的.Interior.Color属性,如Worksheets("yourname").Cells(rowIndex, colIndex).Interior.Color

你到底怎么做? 你是否激活细胞,然后读取循环中的数据? 你有没有尝试过提高macros观性能的提示 ? 如果只有单词(而不是给定单词中的特定字母)被标记为红色,是否可以不使用文本块(使用空格“”作为分隔符)创build临时数组并循环每个单词?

粗糙的前)

 blockOfText = "This is a block of text." myArray = split(blockOfText, " ") for each str in myArray '' If color is red, append to "bad text array" and remove from this one '' next '' Then convert the "myArray" back into a string and place back in the cell