VBA - Zahlen streichen

  • Excel

Es gibt 1 Antwort in diesem Thema. Der letzte Beitrag () ist von fari.

    VBA - Zahlen streichen

    Hallo Experten,

    ich habe eine Tabelle (siehe Anhang) aus der ich aus den Spalten M und N alle Fehler kleiner 2 streichen möchte und anstelle dieser eine Null reinschreiben möchte.

    Danach soll der Vergleichsalgorithmus gestartet werden, um die Bewertung zu erhalten:

    Visual Basic-Quellcode

    1. Public Sub BewertungInlineCT()
    2. Dim arrY As Variant, arrG As Variant, arrP As Variant
    3. Dim r As Long, y As Integer, g As Integer, reslt As Integer
    4. '***Geschwindigkeitsoptimierung Anfang
    5. Application.ScreenUpdating = False
    6. Application.Calculation = xlCalculationManual
    7. '***Auswertung durchführen
    8. With Worksheets("BewertungInlineCT")
    9. For r = 3 To 12
    10. '***Einlesen Zeile Y=Yellow, G=Green, P=Purple
    11. arrY = .Cells(r, "H").Resize(1, 4)
    12. arrG = .Cells(r, "M").Resize(1, 2)
    13. arrP = .Cells(r, "Q").Resize(1, 2)
    14. '***Auswerten "Anzahl Fehler" Yellow
    15. reslt = 0
    16. For y = 1 To UBound(arrY, 2) Step 2
    17. If arrY(1, y) > 0 Or arrY(1, y + 1) > 0 Then reslt = reslt + 1
    18. Next y
    19. .Cells(r, "G") = reslt
    20. '***Auswerten "Anzahl Fehler" Green
    21. reslt = 0
    22. For g = 1 To UBound(arrG, 2)
    23. If arrG(1, g) > 0 Then reslt = reslt + 1
    24. Next g
    25. .Cells(r, "L") = reslt
    26. '***Auswerten "Anzahl richtig"
    27. reslt = 0
    28. For g = 1 To UBound(arrG, 2)
    29. If arrG(1, g) <> 0 And Not IsEmpty(arrG(1, g)) Then
    30. For y = 1 To UBound(arrY, 2) Step 2
    31. If arrG(1, g) >= (arrY(1, y) - 2) And arrG(1, g) <= (arrY(1, y + 1) + 2) Then
    32. reslt = reslt + 1
    33. arrY(1, y) = Empty: arrY(1, y + 1) = Empty
    34. arrG(1, g) = Empty
    35. Exit For
    36. End If
    37. Next y
    38. End If
    39. Next g
    40. .Cells(r, "D") = IIf(reslt > 0, reslt, "")
    41. '***Auswerten "Anzahl Schlupf"
    42. reslt = 0
    43. For g = 1 To UBound(arrG, 2)
    44. If arrG(1, g) <> 0 And Not IsEmpty(arrG(1, g)) Then
    45. reslt = reslt + 1
    46. arrG(1, g) = Empty
    47. End If
    48. Next g
    49. .Cells(r, "E") = IIf(reslt > 0, reslt, "")
    50. '***Auswerten "Anzahl Pseudo"
    51. reslt = 0
    52. For y = 1 To UBound(arrY, 2) Step 2
    53. If arrY(1, y) <> 0 And Not IsEmpty(arrY(1, y)) And _
    54. arrY(1, y + 1) <> 0 And Not IsEmpty(arrY(1, y + 1)) Then
    55. reslt = reslt + 1
    56. arrY(1, y) = Empty: arrY(1, y + 1) = Empty
    57. End If
    58. Next y
    59. .Cells(r, "F") = IIf(reslt > 0, reslt, "")
    60. '***Auswerten "Gesamtentscheid"
    61. .Cells(r, "B") = IIf(.Cells(r, "E") + .Cells(r, "F") > 0, 0, 1)
    62. Next r
    63. End With
    64. '***Geschwindigkeitsoptimierung Ende
    65. Application.ScreenUpdating = True
    66. Application.Calculation = xlCalculationAutomatic
    67. End Sub


    Um die Fehler zu filtern, habe ich vor dem Abschnitt Auswerten Anzahl richtig folgendes eingefügt

    Visual Basic-Quellcode

    1. For g = 1 To UBound(arrP, 2)
    2. If arrP(1, g) < 2 Then arrG(1, g) = "0"
    3. Next g


    Leider funktioniert das aber nicht!

    Kann mir einer bitte sagen, was ich falsch mache?

    Danke!

    Gruß fari
    Dateien
    • Test.xls

      (78,34 kB, 216 mal heruntergeladen, zuletzt: )