How to Split a Cell Diagonally in Excel (Insert Diagonal Line)

Sumit Bansal
Written by

Sumit Bansal is the founder of TrumpExcel.com and a 13-time Microsoft Excel MVP. He started this site in 2013 to share his passion for Excel through easy tutorials, tips, and training videos, helping you master Excel, boost productivity, and maybe even enjoy spreadsheets!

Last updated

When working with data in Excel and creating reports/dashboards, sometimes you would have a need to split a cell diagonally.

This is helpful when you want to show two separate headings within the same cell – one for the row and one for the column (as shown below in cell A1).

Sales data with Month and Country on either side of a diagonal line in cell A1

And being the super awesome spreadsheet tool that Excel is, there is an inbuilt way to easily insert a diagonal line within a cell in Excel.

In this tutorial, I will show you how to quickly split a cell diagonally in Excel, add a header on each side of the line, and fill each half with a different color.

So let’s get started!

Follow along with the example file

Split Cell Diagonally Excel.xlsx

Download

Inserting a Diagonal Line in Excel

Suppose you have a data set as shown below and you want to insert a diagonal line in cell A1 (this is the Practice sheet in the example file).

Sales data with cell A1 selected and empty

Below are the steps to do this:

  1. Select the cell in which you want to insert the line (which is cell A1 in our example)
  2. Click the Home tab
Home tab selected in the Excel ribbon
  1. In the Font group, click on the dialog box launcher icon (the small, tilted arrow at the bottom right of the group)
Dialog box launcher at the bottom right of the Font group

Pro Tip: Instead of steps 2 and 3, you can use the keyboard shortcut Control + 1 (Command + 1 on a Mac) to open the Format Cells dialog box. It works from any tab, so you don’t need to go to the Home tab first.

  1. In the Format cells dialog box, click on the ‘Border’ tab
Format Cells dialog box open on the Border tab
  1. In the Border section, click on the diagonal line icon at the bottom right of the section (as shown below). This will also show you the live preview of how the cell would look like
Diagonal line icon at the bottom right of the Border section, with the preview showing the line

This icon draws the line from the top-left corner of the cell to the bottom-right corner. The icon at the bottom left of the same section draws it the other way, from the bottom-left corner to the top-right corner.

  1. Click Ok

The above steps would insert a diagonal line within the selected cell. In case you have selected multiple cells, this would insert the diagonal line in all the selected cells.

Sales data with a diagonal line in cell A1

You can also customize the line that is inserted.

For example, you can choose the thickness of the line or the color of the line that should be inserted in the cell. The setting is right there in the format cells dialog box, in the Line section of the Border tab (as highlighted below).

You first need to make the Style and Color selections (if needed) and then click on the diagonal border icon.

Style and Color options in the Line section of the Border tab

You can also use the same method to insert a diagonal line in merged cells. The line runs from corner to corner of the whole merged area, not through each of the original cells.

A diagonal border always goes from one corner of the cell to the opposite corner. If you need a line at a different angle, you can draw a line using the Shapes option and place it over the cell.

Split a Cell Diagonally and Add Text on Both Sides

Now that we have the diagonal line in the cell, all you have to do is insert the text for the two headers and space it out a little bit to make it look as if it’s separated by the tilted line.

Let’s say I want to insert the header ‘Month’ at the top and ‘Country’ at the bottom within the same cell (the finished version is on the Diagonal Header sheet in the example file).

Sales data with a diagonal line in cell A1 and no text yet

Below are the steps to do this:

  1. Select the cell that already has the diagonal line
  2. Double click on the cell, or press the F2 key on your keyboard to get into the edit mode
  3. Enter the text ‘Month’ (which is the header title for the first row)
Month entered in cell A1
  1. While still being in the edit mode, hold the ALT key and press the Enter key (or Control + Option + Return if you’re using Mac). This will insert a line break and take your cursor to the next line within that same cell
  2. Enter the text ‘Country’ (which is the header title for the first column)
Month and Country on two lines in cell A1
  1. Press Enter to get out of the edit mode, and then select the cell again
  2. Adjust the formatting (such as make it bold, align text to the left, increase the row height), and add some space characters before the ‘Month’ header to push it a little to the right

To add the spaces, get back into the edit mode and place your cursor before ‘Month’.

Month and Country on either side of the diagonal line in cell A1

The above steps would insert two headers in the same cell and make it appear that these are being divided by a diagonal line.

The number of spaces you need depends on your column width, so keep adding them until ‘Month’ clears the line.

Note that this doesn’t create two cells. Cell A1 still holds one piece of text (the spaces, Month, a line break, and Country), so a formula that refers to A1 gets all of it together.

Also read: Get New Line in Cell in Excel

Use Distributed Alignment Instead of Adding Spaces

Adding space characters works, but you have to adjust them by hand whenever you change the column width. If your two headers are single words, you can let Excel do the spacing for you.

Below I have the same sales data with a diagonal line in cell A1, and I want ‘Country’ below the line and ‘Month’ above it (the finished version is on the Distributed Text sheet in the example file).

Sales data with a diagonal line in cell A1 and no text yet

The cell also has to be big enough for this. At the default column width, the two words stack on top of each other, so make the cell bigger first (here, column A has a width of 20 and row 1 has a height of 42).

The Practice sheet already has this size, so you can try the steps there, after adding the diagonal line to cell A1.

Below are the steps to space out the two headers using Distributed alignment:

  1. Select cell A1, enter the text Country Month (with one space between the two words and no line break), press Enter, and then select cell A1 again
Country Month entered in cell A1
  1. Press Control + 1 to open the Format Cells dialog box and click on the ‘Alignment’ tab
Format Cells dialog box open on the Alignment tab
  1. In the Horizontal drop-down, select Distributed (Indent)
Distributed (Indent) selected in the Horizontal drop-down
  1. In the Vertical drop-down, select Center
Center selected in the Vertical drop-down
  1. Click OK

Excel pushes the first word to the left edge of the cell and the second word to the right edge, which is why ‘Country’ goes first. Each word now sits on its own side of the line.

Country and Month on either side of the diagonal line in cell A1

This only works well with two single-word headers, because Excel spreads every word across the cell. With a third word, one of the words ends up sitting on the line, so use the line break and spaces method for longer headers.

Split a Cell Diagonally and Fill Half With Color

A diagonal border only draws a line. A cell’s fill color always covers the whole cell, so you can’t color just one half of it from the Format Cells dialog box.

To get two colors, you can fill the cell with one color and place a right triangle shape over the other half. One header goes in the cell and the other goes inside the triangle.

Below is the same sales data, and I want the top half of cell A1 in blue to match the month headers and the bottom half in yellow to match the country names (the finished version is on the Two Colors sheet in the example file).

Sales data with blue month headers and yellow country names

‘Country’ has to fit inside the triangle, and in a cell of the default size the text gets cut off. So make the cell bigger first (here, column A has a width of 20 and row 1 has a height of 42).

The Practice sheet already has this size, so you can try the steps there.

Below are the steps to split cell A1 into two colors:

  1. Select cell A1 and pick the color for the top half from the Fill Color option in the Home tab
Fill Color options in the Home tab
  1. Enter the text ‘Month’ in the cell and press Enter. Select cell A1 again, then click on Top Align and Align Right in the Home tab to place it in the top-right corner
Top Align and Align Right in the Alignment group of the Home tab
  1. Click the Insert tab, click on Shapes, and choose Right Triangle from the Basic Shapes section
Right Triangle in the Basic Shapes section of the Shapes menu
  1. Hold the ALT key and drag from the top-left corner of cell A1 to its bottom-right corner (holding ALT makes the shape snap to the cell edges)
Right triangle drawn over cell A1 from corner to corner
  1. In the Shape Format tab, click on Shape Fill and choose the color for the bottom half
Shape Fill options in the Shape Format tab
  1. Click on Shape Outline and choose No Outline
No Outline in the Shape Outline options
  1. With the triangle still selected, type ‘Country’ and press the Escape key to select the whole triangle. Then change the font color to black and make the text bold in the Home tab (the text inside a shape is white by default)
Cell A1 split into blue and yellow halves, with Month and Country in bold

The triangle moves and resizes with the cell when you change the row height or column width, so the split stays lined up.

It’s still a shape sitting on top of the cell though. ‘Country’ lives in the triangle and only ‘Month’ is in cell A1, so a formula that refers to A1 only sees ‘Month’.

You may also see a two-color gradient suggested for this (Format Cells > Fill > Fill Effects). It does give you two colors in one cell, but they blend into each other, so you don’t get a clean split.

Add Two Diagonal Lines to Cross Out a Cell

You can also use both diagonal lines together to put an X through a cell. This is useful when you want to show that a cell is empty on purpose.

Below is sales data where Brazil and the UK have no sales in the first few months, and I want to put an X in those empty cells (the finished version is on the Crossed Out Cells sheet in the example file).

Sales data with empty cells for Brazil and the UK

You can try the steps on any cells on the Practice sheet.

Below are the steps to do this:

  1. Select the cells you want to cross out (B6:C6 and B7:E7 in our example, holding the Control key to select the second range)
The empty cells B6:C6 and B7:E7 selected
  1. Press Control + 1 to open the Format Cells dialog box and click on the ‘Border’ tab
Format Cells dialog box open on the Border tab
  1. In the Border section, click on both the diagonal line icons (the one at the bottom left and the one at the bottom right)
Both diagonal line icons selected in the Border section
  1. Click OK

Each selected cell gets its own X.

An X in each of the empty cells for Brazil and the UK

This puts the X through the cell, not through the text in it. If you want a line through the text instead, use strikethrough.

How to Remove the Diagonal Line in the Cell

If you want to get rid of the line within the cell, just follow the same steps and you can remove it in the same Format Cells dialog box.

Below I have the same sales data with a diagonal line in cell A1, and I want to remove that line (you can try this on the Diagonal Header sheet in the example file).

Sales data with a diagonal line in cell A1

Select cell A1 and press Control + 1 to open the Format Cells dialog box. In the Border tab, click on the None option in the Presets and then click on OK.

None option in the Presets section of the Border tab

This will make the diagonal line go away.

Note that None removes all the borders from the selected cell, not just the diagonal line. If your cell has other borders you want to keep, click on the diagonal line icon again in the Border tab to turn it off, and then click on OK.

So this is how you can easily split the cells diagonally in Excel by inserting a line using the format cells dialog box options.

I hope you found this tutorial useful.

Other Excel tutorials you may also like:

Sumit Bansal

Sumit Bansal

13x Microsoft Excel MVP

Hey! I'm Sumit Bansal, founder of trumpexcel.com and a Microsoft Excel MVP. I started this site in 2013 because I genuinely love Microsoft Excel (yes, really!) and wanted to share that passion through easy Excel tutorials, tips, and Excel training videos. My goal is straightforward: help you master Excel skills so you can work smarter, boost productivity, and maybe even enjoy spreadsheets along the way!

Leave a Comment

Get the FREE 51 Excel Tips Ebook

Enter your details and the free PDF is on its way to your inbox.

Hmm, that didn't go through. Please check your email and try again.

No spam. You'll also get my weekly Excel newsletter. Unsubscribe anytime.

Check your inbox!

The ebook is on its way to your email. It usually lands within a couple of minutes.