首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如果我的单元格没有颜色,则复制它

如果我的单元格没有颜色,则复制它
EN

Stack Overflow用户
提问于 2017-06-14 20:15:42
回答 1查看 1.2K关注 0票数 0

早上好,

我有一个C8:C17的范围有些单元格是红色的,有些是没有颜色的。我希望将不带颜色的单元格转移到A列。

这是我的代码:

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-06-14 20:18:54

下面的代码遍历Range("C8:C17")中的所有单元格,并检查当前单元格是否未着色。如果不是colores,则将其粘贴到A列的下一个空行(从第一行开始)。

代码语言:javascript
复制
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
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44544555

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档