Duchuy2821
Thành viên mới

- Tham gia
- 5/7/19
- Bài viết
- 12
- Được thích
- 0
Chào các anh chị, nhờ mọi người giúp em với ạ. Những màu được tô sử dụng Duplicate nên khi sử dụng code "Cells(i, 1).Interior.ColorIndex" nó đều trả về giá trị -4241
Code của em như sau nhờ mọi người sửa giúp ạ:
Sub xuatgiatritheomau()
Dim d As double
Dim i As Long
Dim dongcuoi As Long
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Sheet1")
dongcuoi = sh.Range("A" & Rows.Count).End(xlUp).Row
On Error Resume Next
d = -4142
For i = 3 To dongcuoi
If Cells(i, 1).Interior.ColorIndex = d Then
Cells(i, 6).Value = Cells(i, 1).Value
End If
Next
End Sub
Code của em như sau nhờ mọi người sửa giúp ạ:
Sub xuatgiatritheomau()
Dim d As double
Dim i As Long
Dim dongcuoi As Long
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Sheet1")
dongcuoi = sh.Range("A" & Rows.Count).End(xlUp).Row
On Error Resume Next
d = -4142
For i = 3 To dongcuoi
If Cells(i, 1).Interior.ColorIndex = d Then
Cells(i, 6).Value = Cells(i, 1).Value
End If
Next
End Sub
Lần chỉnh sửa cuối: