如何检测细胞内容颜色?

时间:2016-10-03 07:41:57

标签: excel vba

我有一个excel细胞。 在单元格中,我有几个段落,每个段落使用不同的字体颜色。 如何使用VBA获取每个段落的字体颜色值?

1 个答案:

答案 0 :(得分:0)

以下是我的解决方案,该网页描述了如何逐个字符地检测给定单元格中的内容颜色:

sheetName = "sheet1"
Set sheet1 = Worksheets(sheetName)
Set theCell = sheet1.Range("G18")
text = theCell.Value

For i = 1 To Len(text)
    If (theCell.Characters(Start:=i, Length:=1).Font.Color = vbBlack) Then
       '....... if the character is in black, do normal procedure
    else
       '........if the character does not in black, handle the exceptional case
    end if 
next 
相关问题