Creating a pseudo Gantt project plan in Excel. For those employees without MS Project, I ran into the following problem. The Excel sheet becomes very sluggish. I am not sure if it is caused by the VBA function I used or the conditional formatting.
The table starts with the task details task, duration, taskStart, taskEnd.
and continues with the calendar part including the fields weekStart and weekEnd. In each calendar cell is a formular
=PseudoGantt(task;duration;taskStart;taskEnd;weekStart;weekEnd)
The macro looks like the following:
Function PseudoGantt(taskName As String, taskLength As Integer, taskStart As Date, taskEnd As Date, weekStart As Date, weekEnd As Date) As String
PseudoGantt = Switch( _
taskName = "", "empty", _
taskStart = taskEnd And taskStart >= weekStart And taskEnd <= weekEnd, "milestone", _
taskLength = 0 And taskStart >= weekStart And taskStart < weekEnd, "summarytask", _
taskLength = 0 And taskEnd <= weekEnd And taskEnd > weekStart, "summarytask", _
taskLength = 0 And taskStart < weekStart And taskEnd > weekEnd, "summarytask", _
taskStart >= weekStart And taskStart < weekEnd, "start", _
taskEnd <= weekEnd And taskEnd > weekStart, "end", _
taskStart < weekStart And taskEnd > weekEnd, "continue", _
True, "empty" _
)
End Function
This will fill the cell with a Gantt state the week is in, which I use as condition for the conditional formatting to color the cell appropriately.
This works, but as I said, it makes Excel very slow.
I thought about replacing the conditional formatting within the VBA custom function, but they do only return values and cannot change the cell color or the like.
Question:
- is it the custom function or the conditional formatting what makes Excel slow?
- How can I color the cells from VBA?
- Should I rather leave the calendar cells empty and let VBA do the coloring without the workaround to write and content into the cells?
- If your answer to 3. is "yes". How to do that?
Thanks for listening.
Side note: sorry, can't post the screenshot yet (Anti-Spam-Filter)