Wert dupliziert in einer Matrix-VBA

414
Alex Silva

Ich habe diesen Code, um die kleinste Zahl, die gefunden werden kann, und seine Spalte in jeder Zeile der Matrix zu erhalten und in Zellen zu schreiben (Spalte, in der sie gefunden wurde, Zeile).

Dies ist die Matrix am Anfang
Matrix am Anfang

Ich führe den Code aus und das ist, was
Code ausgeführt wird

Der Code funktioniert wie beabsichtigt, er findet immer die kleinste Zahl in einer Reihe, macht sie orange und kopiert die richtige Maschine.

Das Problem ist nun, wie kann ich das Programm die Spalte "Gesamt" jedes Mal überprüfen lassen, wenn es mehr als eine kleinste Zahl in der gleichen Zeile gibt und orange machen und die Zahl kopieren.

Es sollte dies mit der Matrix
tun, was tun soll

Ändern Sie die Zahl orange in Zeile 5 und kopieren Sie diese Nummer in Zellen ("K3").

Dies ist der Code, den ich gerade habe

Dim tarefas, maxcolunaspossiveis, coluna As Long tarefas = 4 maqs = 5 maxcolunaspossiveis = (maqs + 4) + tarefas + 1 Cells(1, maxcolunaspossiveis) = "Total"  For i = 2 To tarefas + 1  For q = 2 To maqs + 1 Cells(q, maxcolunaspossiveis) = Application.Sum(Range(Cells(q, maxcolunaspossiveis - tarefas), Cells(q, maxcolunaspossiveis - 1))) Next q  menor = WorksheetFunction.Small(Range(Cells(i, 2), Cells(i, maqs + 1)), 1) coluna = Application.Match(menor, Range(Cells(i, 2), Cells(i, maqs + 1)), 0)  Cells(i, coluna + 1).Interior.ColorIndex = 45 Cells(coluna + 1, Cells(coluna + 1, maxcolunaspossiveis).End(xlToLeft).Column + 1) = menor  Next i  For q = 2 To maqs + 1 Cells(q, maxcolunaspossiveis) = Application.Sum(Range(Cells(q, maxcolunaspossiveis - tarefas), Cells(q, maxcolunaspossiveis - 1))) Next q   End Sub 

Ich weiß, dass ich so etwas haben kann, um die kleinste Anzahl in dieser Reihe zu erhalten

Dim iVal As Integer iVal = Application.WorksheetFunction.CountIf(Range(Cells(i, 2), Cells(i, maqs + 1)), menor)  If iVal = 1 Then ............What i currently have ..... Else ............What do i do here?......... 

Kann mir jemand helfen?

0

0 Antworten auf die Frage