Explanation

In this example if a task is marked “Done”, then it is considered complete. The goal is to calculate the percent complete for the project by showing the ratio of complete tasks to total tasks, expressed as a percentage. The formula in F6 is:

=COUNTA(C5:C11)/COUNTA(B5:B11)

At the core, this formula simply divides tasks complete by the total task count:

=complete/total

which is then formatted as a percentage . To count completed tasks, we count non-blank cells in the range C5:C11 with the COUNTA function :

=COUNTA(C5:C11) // returns 4

Unlike the COUNT function , which counts only numeric values , COUNTA will count cells that include numbers or text.

To count total tasks, we count non-blank cells in the range C5:C11, again with COUNTA:

COUNTA(B5:B11) // returns 7

After COUNTA runs, we can simply the formula to:

=4/7 // 0.571428571428571

Four divided by 7 results in the decimal number 0.571428571428571 which is displayed as 57% once the Percentage number format is applied.

Explanation

The RANDBETWEEN function takes two numbers, a bottom and top number, and generates a random integer in between. Dates in Excel are serial numbers, so you can use the DATE function to create the lower number and the upper number. RANDBETWEEN then generates a number that falls between these two date values.

Notes:

  1. The result of this formula must be formatted as a date to display correctly.
  2. The RANDBETWEEN function is volatile and will generate new numbers whenever a change occurs on the worksheet. That includes any edits to the worksheet, or simply opening the workbook.
  3. To prevent random numbers from being calculated again, copy the formulas, then use Paste Special > Values to replace the formulas with their calculated values.

Random workdays

To generate random workdays, you can add the WORKDAY function like this:

=WORKDAY(RANDBETWEEN(date1,date2)-1,1)

The WORKDAY function ensures that the date returned is a work day and not a weekend or holiday. Note that WORKDAY will shift dates that fall on weekends or holidays to the next working day, so you may see dates that extend beyond date2.