0

I have code that loop in the array. I want when it finishes every item in the array, it makes the cell green

Dim ArrayDictionaryofItems1 As Object, Items1 As Variant, i1 As Long, Item1 As Variant
Set ArrayDictionaryofItems1 = CreateObject("Scripting.Dictionary")
Dim dataRange As Range

  ActiveSheet.Range("$d$34:$d$10000").Select
  Selection.Copy
  ActiveSheet.Range("c$4:$c$10000").Select
  ActiveSheet.Range("c$4:$c$10000").PasteSpecial Paste:=xlPasteValues
  ActiveSheet.Range("$c$4:$c$10000").RemoveDuplicates Columns:=1, Header:=xlNo
  Range("C2") = Application.WorksheetFunction.CountA(Range("C4:C350"))

  With ActiveSheet
    Items1 = Range(.Range("c4"), .Cells(Rows.Count, "c").End(xlUp))
    For i1 = 1 To UBound(Items1, 1)
      ArrayDictionaryofItems1(Items1(i1, 1)) = 1
    Next
            
    For Each Item1 In ArrayDictionaryofItems1.keys
      erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
      ActiveSheet.Range("d34").AutoFilter field:=1, Criteria1:=Item1
            
      Cells("d34").Interior.Color = 4

I have code that loop in the array. I want when it finishes every item in the array, it makes the cell green

pic

Dominique
  • 16,450
  • 15
  • 56
  • 112
Saleh
  • 1
  • 1
  • `Cells` doesn't take a string address like that. I think you want `Range("D34").Interior.Color = RGB(0, 255, 0)`. Also, I think that you might benefit from reading [How to avoid using Select in Excel VBA](https://stackoverflow.com/q/10714251/4996248). – John Coleman Nov 14 '22 at 02:29
  • no i dont want range(d34) i want the item one by one make it green in colom C Because I know at what stage the code reached And when something goes wrong, I know what stage it has reached And I know what's been done and the rest The values ​​in column c are the values ​​in column d but are unique – Saleh Nov 14 '22 at 09:12
  • Put the color code at the bottom of the loop? – John Coleman Nov 14 '22 at 14:47

0 Answers0