Forum Discussion
GKE2019
Apr 12, 2022Brass Contributor
Planning days colour
Hello,
I have here a planning, and I would like that it automatically puts colours in.
For Example:
Startdate 11/02/2022
Duedate 18/02/2022
And it would colour all the cells between it.
At the moment I have this
RowDescription = 3
rowFirstData = 4
ColTaskName = "A"
ColBucketName = "B"
ColAssignedTo = "C"
ColStartDate = "D"
ColDueDate = "E"
ColLate = "F"
ColStartdayNums = "G"
nColFirstData = 1
nColLastData = 6
Style01 = "01"
Style02 = "02"
Style03 = "03"
Style04 = "04"
Style05 = "05"
Style06 = "06"
Style07 = "07"
Style08 = "08"
For i = rowFirstData To qRows
If Range(oColNameE & i).Value = vbNullString Then
ElseIf Range(oColNameD & i).Value = vbNullString Then
Else:
startDay = Range(ColStartDate & i).Value
endDay = Range(ColDueDate & i).Value
deltaDays = endDay - startDay
startdayCol = Range(ColStartdayNums & i).Column
startdayCol = Cells(i, (startdayCol + startDay - 1)).Column
enddayCol = Cells(i, startdayCol + deltaDays).Column
If Range(ColLate & i).Value = "true" Then
StyleStr = "Bad"
ElseIf Range(ColBucketName & i).Value = "Mee Bezig" Then
StyleStr = "02"
ElseIf Range(ColBucketName & i).Value = "Planning" Then
StyleStr = "01"
ElseIf Range(ColBucketName & i).Value = "On Hold" Then
StyleStr = "04"
ElseIf Range(ColBucketName & i).Value = "Uitbesteed" Then
StyleStr = "05"
ElseIf Range(ColBucketName & i).Value = "Controlle" Then
StyleStr = "03"
ElseIf Range(ColBucketName & i).Value = "Klaar" Then
StyleStr = "08"
ElseIf Range(ColBucketName & i).Value = "Vrij" Then
StyleStr = "06"
ElseIf Range(ColBucketName & i).Value = "Op locatie" Then
StyleStr = "07"
End If
If StyleStr <> "" Then
Range(Cells(i, startWeekCol), Cells(i, endWeekCol)).Style = StyleStr
End If
End If
Next iBut so far I get an type mismatch at line 29.
What am I doing wrong?
2 Replies
- Riny_van_EekelenPlatinum Contributor
GKE2019 Why make it difficult with VBA if you can use conditional Formatting. Example attached.
- GKE2019Brass ContributorBecause it has to be in a loop since it is going to be updated everyday, and there might come more data in the rows