1

我的桌子上有一些彩色的单元格。我需要将它们的值复制到另一列。这是我的宏:

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

我正在尝试寻找另一种方法来复制彩色单元格的值。现在我正在尝试做:

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

字符串有问题

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

这就是我需要的:http://postimage.org/image/4sjvimv35/

4

1 回答 1

1

要获取有关颜色的代码:

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

为了获得您需要的效果,方法可能会有所不同。但是,我不确定这是否是您问题的一部分。

于 2012-06-27T09:41:33.483 回答