2017-06-14 57 views
0

早上好,如果我的细胞没有颜色,然后将其复制

我有一个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 

回答

4

下面的代码通过Range("C8:C17")所有细胞循环,如果当前单元格不着色检查。如果它不是colores,则将它粘贴到下一个空行(从第一行开始)的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 
+0

它的工作原理!我在新专栏中遇到了一个问题,谢谢! – babou

+2

@babou your'e欢迎:)随时标记为“答案” –

相关问题