我想在macros中改变单元格的文本颜色

我有一个macros复制垂直列中的组单元格的最后单元格值,例如,

Sub copy_down() Dim r As Range, rr As Range, N As Long N = Cells(Rows.Count, "A").End(xlUp).Row Set r = Range(Cells(1, "A"), Cells(N, "A")).SpecialCells(xlCellTypeBlanks) For Each rr In r rr.FillDown Next End Sub 

编辑(增加了一个额外的行),这里是:

 Sub copy_down() Dim r As Range, rr As Range, N As Long N = Cells(Rows.Count, "A").End(xlUp).Row Set r = Range(Cells(1, "A"), Cells(N, "A")).SpecialCells(xlCellTypeBlanks) For Each rr In r rr.FillDown Next Cells(N + 1, "A").FillDown End Sub 

请在此macros中添加一个更多的function。 我想要改变用红色复制的单元格的文本颜色,就像添加:

 'change formatting to your liking: formulaCell.Font.Bold = True formulaCell.Font.Color = RGB(255, 0, 0) 

我以前的问题忘了问这个问题。

如果您只想更改已填充的单元格,请在循环中添加格式更改为rr

 Sub copy_down() Dim r As Range, rr As Range, N As Long N = Cells(Rows.Count, "A").End(xlUp).Row Set r = Range(Cells(1, "A"), Cells(N, "A")).SpecialCells(xlCellTypeBlanks) For Each rr In r with rr .FillDown .Font.Bold = True .Font.Color = RGB(255, 0, 0) end with Next End Sub