2017-06-14 38 views
0

おはよう、は、それが

私はC8での範囲を持ってコピーします。 私は色のない細胞が列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 welcome :) "Answer"とマークするのは自由です。 –