Ja, es bezieht sich alles auf das gleiche Worksheet.
Heißt es ist besser wenn das Makro so aussieht?
Sub Prüfung_1()
With Worksheets("Sheet1")
If Application.Range("BPK2").Value = "x" Then
For y = Application.Range("BQC1").Column To Application.Range("DTL1").Column
If Application.Cells(1, y).Value < Application.Range("KC2").Value Or _
Application.Cells(1, y).Value > Application.Range("KD2").Value Or _
Application.Cells(3, y).Value = 1 _
And Application.Cells(1, y).Value >= Application.Range("KC2").Value _
And Application.Cells(1, y).Value <= Application.Range("KD2").Value _
Then
Application.Cells(2, y).Value = 0
Else
Application.Cells(2, y).Value = 1
End If
Next
Application.Range("BQA2").Value = WorksheetFunction.Sum(Application.Range("BQC2:DTL2"))
If Application.Range("BQA2").Value = 0 Then
Call Ende(3, 10, 13, 14, "BPN2", "BPO2")
Else: Call Prüfung_2
End If
Else: Call Prüfung_2
End If
End With
End Sub
Oder wäre folgende Lösung besser?
Sub Prüfung_1()
If Sheets("Sheet1").Range("BPK2").Value = "x" Then
For y = Sheets("Sheet1").Range("BQC1").Column To Sheets("Sheet1").Range("DTL1").Column
If Sheets("Sheet1").Cells(1, y).Value < Sheets("Sheet1").Range("KC2").Value Or _
Sheets("Sheet1").Cells(1, y).Value > Sheets("Sheet1").Range("KD2").Value Or _
Sheets("Sheet1").Cells(3, y).Value = 1 _
And Sheets("Sheet1").Cells(1, y).Value >= Sheets("Sheet1").Range("KC2").Value _
And Sheets("Sheet1").Cells(1, y).Value <= Sheets("Sheet1").Range("KD2").Value _
Then
Sheets("Sheet1").Cells(2, y).Value = 0
Else
Sheets("Sheet1").Cells(2, y).Value = 1
End If
Next
Sheets("Shee1").Range("BQA2").Value = WorksheetFunction.Sum(Sheets("Sheet1").Range("BQC2:DTL2"))
If Sheets("Sheet1").Range("BQA2").Value = 0 Then
Call Ende(3, 10, 13, 14, "BPN2", "BPO2")
Else: Call Prüfung_2
End If
Else: Call Prüfung_2
End If
End With
End Sub
Danke!
|