bei folgendem Code
Sub CalColor()
Dim CalRow As Long, CalLastRow As Long 'first/last Row Calendar
Dim CalCol As Long, CalLastCol As Long 'first/last Column Calendar
Dim LoPRow As Long, LoPLastRow As Long 'first/last Row LoP
Dim LoPCol As Long, LoPLastCol As Long 'first/last Column LoP
Dim wsLoP As Worksheet, wsCal As Worksheet
Dim CalDay As Range 'Date from Calendar
Dim Counter As Integer 'Counter for hits in LoP
Dim rngLoPDates As Range 'Date Area in LoP
Dim rngCalArea As Range 'Calendar Area
Dim rngValence As Range 'Row with valence of columns
Set wsLoP = Worksheets("ListOfPatients")
Set wsCal = Worksheets("Calendar")
CalRow = 3
CalCol = 1
CalLastRow = wsCal.Cells(Rows.Count, CalCol).End(xlUp).Row
CalLastCol = wsCal.Cells(CalRow, Columns.Count).End(xlToLeft).Column
Set rngCalArea = Range(Cells(CalRow, CalCol), Cells(CalLastRow, CalLastCol))
LoPRow = 8
LoPLastRow = wsLoP.Cells(Rows.Count, CalRow).End(xlUp).Row
LoPCol = 4
LoPLastCol = 20
Set rngValence = Range(Cells(6, LoPCol), Cells(6, LoPLastCol))
Set rngLoPDates = Range(Cells(LoPRow, LoPCol), Cells(LoPLastRow, LoPLastCol))
For Each CalDay In Range(rngCalArea)
Counter = DaysCount(CalDay, rngLoPDates, rngValence)
If Counter > 1 Then
CalDay.Interior.ColorIndex = 1 'big mistake workamount overflow
ElseIf Counter = 0.9 Or Counter = 1 Then
CalDay.Interior.ColorIndex = 2
ElseIf Counter = 0.6 Then
CalDay.Interior.ColorIndex = 3
ElseIf Counter = 0.3 Then
CalDay.Interior.ColorIndex = 4
End If
Next 'CalDay
End Sub
Steigt Excel mit der FehlermeldungLaufzeitfehler 1004 Anwendungs oder objektdefinierter Fehler
in der Zeile For Each CalDay In Range(rngCalArea)
aus.
Könnte mal jemand schauen, ob ich da einen Syntaxfehler eingebaut habe, oder ob es mal wieder meine verquerte Logik ist, die mir da ins Kreuz tritt?
Danke,
PQuest:-)