Option Explicit
Sub DeinCode()
Dim o As Integer
Dim x As Integer 'Zählvariable
For o = 2004 To 3 Step -1
If [Sheets("OverviewX").Cells(o, 1)] >= [Sheets("Calculus").Cells(49,3)] Then
Sheets("OverviewX").Cells(6, 4).Value = Sheets("Calculus").Cells(o, 6).Value
Sheets("OverviewX").Cells(6, 9).Value = Sheets("Calculus").Cells(60, 3).Value
Sheets("OverviewX").Cells(6, 12).Value = "0" - Sheets("Calculus").Cells(49, 3)
x = x + 1
End If
'Exit For = Murks - egal wo es steht, die Schleife wird beendet !
Next
MsgBox "Anzahl Bedingung erfüllt = " & CStr(x) & "mal"
End Sub
Sub MeinCode()
Dim o As Integer
Dim x As Integer 'Zählvariable
For o = 2004 To 3 Step -1
Rem **************************************************************************
'If [Sheets("OverviewX").Cells(o, 1)] >= [Sheets("Calculus").Cells(49,3)] Then
Rem Denn - was sollen die [ ] Brackets ?
Rem die evaluieren und die Bedingung ist immer erfüllt
Rem **************************************************************************
If Sheets("OverviewX").Cells(o, 1) >= Sheets("Calculus").Cells(49, 3) Then
Sheets("OverviewX").Cells(6, 4).Value = Sheets("Calculus").Cells(o, 6).Value
Sheets("OverviewX").Cells(6, 9).Value = Sheets("Calculus").Cells(60, 3).Value
Sheets("OverviewX").Cells(6, 12).Value = "0" - Sheets("Calculus").Cells(49, 3)
x = x + 1
End If
'Exit For = Murks - egal wo es steht, die Schleife wird beendet !
Next
MsgBox "Anzahl Bedingung erfüllt = " & CStr(x) & "mal"
End Sub
|