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:
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.