简体   繁体   English

将内部颜色复制到单元格

[英]Copy interior color to cell

I have got table that has some cells colorized. 我的桌子上有一些彩色的单元格。 I need to copy their value to another column. 我需要将其值复制到另一列。 Here are my macros: 这是我的宏:

Sub exa()

Dim rng As Range
Dim row As Range
Dim cell As Range

Set rng = Range("B:AJ")

For Each row In rng.Rows
  For Each (cell).Interior.Color = RGB(138, 255, 132) in row.Cells

    Area.Offset(, 40).Value = Area.Value

  Next cell
Next row

End Sub

I am trying to find another approach to copy values of collorized cells. 我试图找到另一种复制带颜色的单元格的值的方法。 Now I am trying to do: 现在我正在尝试做:

Sub test()
Dim rng As Range
Dim r As Integer
Set rng = ActiveSheet.Range("B2:I8")


For Each Row In rng.Rows
    For Each cell In Row.Cells
       If cell.Interior.Color = RGB(138, 255, 132) Then
      '  cell.Copy Destination:=Sheets("HMPB").Range("AU")
          Area.Offset(, 40).Value = Area.Value
       Next cell
Next Row

End Sub

There is something wrong with the string 字符串有问题

(cell).Interior.Color = RGB(138, 255, 132) in row.Cells

This is what I need: 这就是我需要的: http://postimage.org/image/4sjvimv35/

To get the code going regarding the color: 要获得有关颜色的代码,请执行以下操作:

For Each row In rng.Rows
    For Each cell In row.cells
        cell.Interior.Color = RGB(138, 255, 132)
    Next cell
Next row

To get the effect that you need, the approach may be differently. 为了获得所需的效果,方法可能有所不同。 However, I'm not sure if this is part of your question. 但是,我不确定这是否是您的问题的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM