早上好,
我在 C8:C17 中有一个范围,有些单元格是红色的,有些是没有颜色的。我希望没有颜色的单元格被转移到 A 列。
这是我的代码:
Dim a As Long
a = 1 'we set the row where we start filling in the single sames
If Range("C8:C17").Interior.ColorIndex = xlColorIndexNone Then
Cells(a, "A").Value = Range("C8:C17").Value
a = a + 1
End If
下面的代码循环遍历 中的所有单元格Range("C8:C17")
,并检查当前单元格是否未着色。如果不是颜色,则将其粘贴到下一个空行(从第一行开始)的 A 列。
Option Explicit
Sub CopyColCells()
Dim a As Long
Dim C As Range
a = 1 'we set the row where we start filling in the single sames
For Each C In Range("C8:C17")
If C.Interior.ColorIndex = xlColorIndexNone Then
Cells(a, "A").Value = C.Value
a = a + 1
End If
Next C
End Sub
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句