5 Ways To Exclude Sundays In Excel

Intro

Discover how to exclude Sundays in Excel with 5 easy methods. Learn to remove Sundays from date ranges, use weekday functions, and create custom formulas to automate tasks. Master Excels WORKDAY, NETWORKDAYS, and DATE functions to boost productivity and accuracy. Simplify your data analysis and reporting by excluding Sundays with these expert tips.

Working with dates in Excel can be a challenge, especially when you need to exclude Sundays from your calculations. Whether you're creating a calendar, tracking project timelines, or analyzing sales data, excluding Sundays can be a crucial step. In this article, we'll explore five ways to exclude Sundays in Excel, making it easier for you to manage your data and focus on the insights that matter.

Why Exclude Sundays in Excel?

Exclude Sundays in Excel

Before we dive into the methods, let's quickly discuss why excluding Sundays is important. In many industries, Sundays are considered non-working days, and including them in calculations can skew results. For example, if you're calculating project duration or tracking sales trends, including Sundays can lead to inaccurate conclusions. By excluding Sundays, you can ensure that your data reflects only working days, providing a more accurate representation of your business.

Method 1: Using the WORKDAY Function

Excel WORKDAY Function

The WORKDAY function is a built-in Excel function that calculates the number of working days between two dates, excluding weekends and holidays. To exclude Sundays using this function, follow these steps:

  • Select the cell where you want to display the result
  • Type =WORKDAY(start_date, end_date, [holidays])
  • Replace start_date and end_date with the dates you want to calculate between
  • Optional: add holidays as an array of dates to exclude

For example, to calculate the number of working days between January 1, 2022, and December 31, 2022, excluding Sundays, you would use the following formula:

=WORKDAY(A2, B2)

Assuming A2 contains the start date (January 1, 2022) and B2 contains the end date (December 31, 2022).

Method 1 Variations

You can also use variations of the WORKDAY function to exclude Sundays:

  • WORKDAY.INTL: This function allows you to specify the weekend days to exclude.
  • WORKDAY.DAYS: This function returns the number of working days between two dates, excluding weekends and holidays.

Method 2: Using Conditional Formatting

Excel Conditional Formatting

Conditional formatting is a powerful tool in Excel that allows you to highlight cells based on specific conditions. To exclude Sundays using conditional formatting, follow these steps:

  • Select the cells that contain the dates you want to format
  • Go to the Home tab > Conditional Formatting > New Rule
  • Select "Use a formula to determine which cells to format"
  • Enter the formula =WEEKDAY(A1)=1, assuming A1 is the first date cell
  • Click Format and select a format to apply to Sundays
  • Click OK

This will highlight Sundays in the selected range.

Method 2 Variations

You can also use other formulas to exclude Sundays using conditional formatting:

  • =WEEKDAY(A1, 2)=1: This formula uses the second argument (2) to specify that Sunday is the first day of the week.
  • =TEXT(A1, "dddd")="Sunday": This formula uses the TEXT function to convert the date to a string and checks if it's equal to "Sunday".

Method 3: Using VBA Macros

Excel VBA Macros

VBA macros can be used to automate tasks in Excel, including excluding Sundays. To create a macro that excludes Sundays, follow these steps:

  • Open the Visual Basic Editor (VBE) by pressing Alt+F11 or navigating to Developer > Visual Basic
  • Create a new module by clicking Insert > Module
  • Paste the following code:

Sub ExcludeSundays() Dim cell As Range For Each cell In Selection If Weekday(cell.Value) = 1 Then cell.ClearContents End If Next cell End Sub

  • Save the module and close the VBE

To run the macro, select the range of cells containing the dates and press Alt+F8 to open the Macro dialog box. Select the "ExcludeSundays" macro and click Run.

Method 3 Variations

You can modify the VBA macro to exclude Sundays in different ways:

  • Use a loop to iterate through the cells and check if the date is a Sunday.
  • Use the WORKDAY function to calculate the number of working days between two dates.

Method 4: Using Power Query

Excel Power Query

Power Query is a powerful data manipulation tool in Excel that allows you to transform and filter data. To exclude Sundays using Power Query, follow these steps:

  • Select the range of cells containing the dates
  • Go to the Data tab > From Table/Range
  • Click on the "Add Column" tab and select "Custom Column"
  • Enter the formula =Date.From(Text.Combine({Text.From([Date]), " ", Text.From(Day([Date]))})) and click OK
  • Go to the "Filter" tab and select "Sunday" from the dropdown list

This will exclude Sundays from the data.

Method 4 Variations

You can also use other Power Query formulas to exclude Sundays:

  • =Date.From(Text.Combine({Text.From([Date]), " ", Text.From(Day([Date]))})) > #date(1900, 1, 1) + #duration(1, 0, 0, 0) * Weekday([Date], 1)
  • =Date.From(Text.Combine({Text.From([Date]), " ", Text.From(Day([Date]))})) < #date(1900, 1, 1) + #duration(1, 0, 0, 0) * Weekday([Date], 1)

Method 5: Using Date Functions

Excel Date Functions

Excel provides various date functions that can be used to exclude Sundays. To exclude Sundays using date functions, follow these steps:

  • Select the cell where you want to display the result
  • Type =DATE(YEAR(A1), MONTH(A1), DAY(A1) - WEEKDAY(A1, 2) + 1)
  • Replace A1 with the date cell

This formula calculates the date of the previous working day.

Method 5 Variations

You can also use other date functions to exclude Sundays:

  • =DATE(YEAR(A1), MONTH(A1), DAY(A1) - WEEKDAY(A1, 1) + 1)
  • =WORKDAY(DATE(YEAR(A1), MONTH(A1), DAY(A1)), -1, [holidays])

By following these five methods, you can exclude Sundays in Excel and ensure that your data reflects only working days. Whether you're using the WORKDAY function, conditional formatting, VBA macros, Power Query, or date functions, there's a method that suits your needs.

Jonny Richards

Love Minecraft, my world is there. At VALPO, you can save as a template and then reuse that template wherever you want.