How-to recipes · Charts

How to make a Gantt chart with conditional formatting in Excel

Build a simple project timeline in the grid: dates across the top, tasks down the side, and a formula rule that colours each task's days.

Intermediate AND SEQUENCE TODAY WORKDAY NETWORKDAYS WEEKDAY IF

A Gantt chart shows each task of a project as a horizontal bar across a calendar, so you can see what happens when, what overlaps and what comes next. Excel has no Gantt chart type, and building one from a stacked bar chart is fiddly. A much simpler approach colours cells in the worksheet: dates run across the top, tasks run down the side, and a conditional formatting rule fills every cell where the date falls between a task's start and end. Change a date and the bar moves.

The layout

Task names in column A, start dates in B, end dates in C, and one column per day from D onwards with the date in row 1. In the small example below, three days of June 2026 are shown; a real plan would have weeks or months of columns.

Step 1: the date header

Type the project's first day in D1. In Microsoft 365, spill all the following days at once with =SEQUENCE(1,60,B2), which returns 60 consecutive dates starting with the first task's start date. In Excel 2016 and 2019, type =D1+1 in E1 and copy it to the right. Format the header as d-mmm and narrow the columns to about 4 characters wide. For weekly columns, use =D1+7 instead.

Step 2: test the rule in a cell

A day belongs to a task when it is on or after the start and on or before the end. Check the logic in the grid first:

E2fx=AND(E$1>=$B2,E$1<=$C2)
ABCDEF
1TaskStartEnd1-Jun2-Jun3-Jun
2Plan1-Jun2-JunTRUE
3Build2-Jun3-Jun
4Test3-Jun3-Jun

2 June is within Plan's dates (1-2 June), so the test is TRUE. Dates are shown as d-mmm.

Result: TRUE

The references are the heart of the trick: E$1 keeps the row fixed so every cell reads the date from the header row, and $B2 / $C2 keep the columns fixed so every cell reads its own task's start and end. Cell references: relative, absolute and mixed explains mixed references.

Step 3: create the rule

  1. Select the whole calendar area, for example D2:BK20, with D2 as the active cell.
  2. Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format.
  3. Enter =AND(D$1>=$B2,D$1<=$C2).
  4. Click Format > Fill, choose a strong colour, and click OK twice.

Every task now has a coloured bar. Edit a start or end date and the bar moves or stretches immediately. Add new tasks in the rows below and they get bars automatically, as long as the rows are inside the rule's range.

Microsoft 365: see the bars as a formula

If you want the timeline without formatting, for example to paste into an email, a single formula can draw it with characters:

D2fx=IF((D1:F1>=B2:B4)*(D1:F1<=C2:C4),"■","")
ABCDEF
1TaskStartEnd1-Jun2-Jun3-Jun
2Plan1-Jun2-Jun■■
3Build2-Jun3-Jun■■
4Test3-Jun3-Jun■

Rows are tasks, columns are days. Each comparison broadcasts the header row against the task columns.

Useful extra rules

  • Today line: a second rule =D$1=TODAY() with a red border marks the current day across all tasks. Put it above the bar rule in Manage Rules.
  • Weekends: =WEEKDAY(D$1,2)>5 with a light grey fill shades Saturdays and Sundays (WEEKDAY).
  • Progress: add a % complete column E and a darker colour for the finished part: =AND(D$1>=$B2,D$1<$B2+($C2-$B2+1)*$E2).
  • Milestones: for tasks where start equals end, a rule =AND($B2=$C2,D$1=$B2) with a diamond-coloured fill makes them stand out.

Working out the dates

Instead of typing end dates, calculate them from a duration in working days with WORKDAY: =WORKDAY(B2,D2-1) where D2 holds the number of days. Make a task start after its predecessor with =WORKDAY(C2,1). NETWORKDAYS gives the working-day length of an existing task. See How to count working days between two dates in Excel.

Pitfalls

  • Rule written for the wrong cell. The formula must refer to the active cell of the selection (D2 here). If the bars appear shifted by a row or column, edit the rule and check the references.
  • Header dates as text. If row 1 contains text like "1-Jun" instead of real dates, nothing is coloured. Type real dates and format them.
  • Time in the dates. Start and end values with times (from a project tool) make the comparisons fail on the last day. Use INT($C2).
  • Long projects. Daily columns for a year are 365 columns; switch to weekly columns and compare with week start dates.
⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 14 KB

More how-to recipes