Forum Discussion

GKE2019's avatar
GKE2019
Brass Contributor
Apr 12, 2022

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 i

But so far I get an type mismatch at line 29.

What am I doing wrong?

2 Replies

    • GKE2019's avatar
      GKE2019
      Brass Contributor
      Because it has to be in a loop since it is going to be updated everyday, and there might come more data in the rows