As you did not give an example of the code I rode this from here with what you went through. Do the tests or check out the logic here and try to apply to your case.
Insert the following code into the worksheet to have the values analyzed and separated:
Private Sub Worksheet_Deactivate()
Worksheets("AÇÕES PDCA FECHADAS").Range("A1:L16").ClearContents
For I = 13 To 25
If Worksheets("A3").Cells(I, 26) = "OPEN" Then Exit For
If Worksheets("A3").Cells(I, 26) = "CLOSED" Then
Linha = Application.WorksheetFunction.CountA(Worksheets("AÇÕES PDCA FECHADAS").Range("A1:L16"))
Linha = Linha + 2
Worksheets("AÇÕES PDCA FECHADAS").Cells(Linha, 1) = Worksheets("base").Cells(I, 16)
Worksheets("AÇÕES PDCA FECHADAS").Cells(Linha, 2) = Worksheets("base").Cells(I, 17)
Worksheets("AÇÕES PDCA FECHADAS").Cells(Linha, 3) = Worksheets("base").Cells(I, 18)
Worksheets("AÇÕES PDCA FECHADAS").Cells(Linha, 4) = Worksheets("base").Cells(I, 19)
Worksheets("AÇÕES PDCA FECHADAS").Cells(Linha, 5) = Worksheets("base").Cells(I, 20)
Worksheets("AÇÕES PDCA FECHADAS").Cells(Linha, 6) = Worksheets("base").Cells(I, 21)
Worksheets("AÇÕES PDCA FECHADAS").Cells(Linha, 7) = Worksheets("base").Cells(I, 22)
Worksheets("AÇÕES PDCA FECHADAS").Cells(Linha, 8) = Worksheets("base").Cells(I, 23)
Worksheets("AÇÕES PDCA FECHADAS").Cells(Linha, 9) = Worksheets("base").Cells(I, 25)
Worksheets("AÇÕES PDCA FECHADAS").Cells(Linha, 10) = Worksheets("base").Cells(I, 25)
Worksheets("AÇÕES PDCA FECHADAS").Cells(Linha, 11) = Worksheets("base").Cells(I, 26)
Worksheets("AÇÕES PDCA FECHADAS").Cells(Linha, 12) = Worksheets("base").Cells(I, 27)
End If
Next I
End Sub
Good Morning. Stack Overflow focuses on questions and answers to concrete cases where there has been difficulty in developing a solution. Have you developed any code? Have you tried something that didn’t work? From what I’ve seen it seems like what you want is a ready-made solution, but here the collaboration is for questions. Study some basic VBA and draft your own solution. When trying to implement it before, if there is an error come back here we help.
– Rodrigo Sassaki