Google Docs How to Draw 45 Degree Line on Graph
Those who switch from using Excel to Google Sheets often miss the fact that there is no in-built feature in Google Sheets to split cells diagonally.
But if you still want to insert a diagonal line in Google Sheets, there are some workarounds that should work.
In this tutorial, I will show you a couple of methods to insert a diagonal line in Google Sheets.
Inserting the Diagonal Line With Text in the Cell
Since there is no in-built way to insert a diagonal line in a cell in Google Sheets, let's get a bit creative.
Suppose I have a dataset as shown below and I want to have a diagonal line in cell A1 so that below the line, I have the text 'Store' and above it, I have the text 'Month'
Let's see a couple of methods to do this:
Using the Tilt Feature
While you cannot insert a diagonal line in Google Sheets, you can insert a regular horizontal line and then tilt it to make it look like a diagonal one.
Below are the steps to use the Tilt feature to insert a diagonal line:
- Select the cell that you want to split using a diagonal line (cell A1 in this example)
- Enter the text "Month" (which is the header for the first row)
- With the cell in the edit mode, hold the Alt key and press the Enter key (Option + Enter if using Mac). This would insert a line break and you would be able to type in the next line within the same cell.
- Enter a series of dashes (———-)
- Again, hold the ALT key and press the Enter key
- Enter the text "Store" (which is the header for Column A)
At this point, your cell would look something as shown below.
Now all you need to do is tilt the content of this cell so that the horizontal line becomes diagonal.
Below are the steps to do this:
- Select the cell (A1 in this example)
- Click the Format option in the menu
- Hover the cursor over the 'Text Rotation' option
- In the options that appear, click on 'Tilt down'
- Adjust the row height and column width accordingly (I made it bold, aligned the text to the middle and to the center)
The above steps would give you something as shown below.
While this is not perfect, it gets the work done. It gives an impression that the text above the line is the header for the row and the text below the line is the header for the column
Note: When using this technique, you can not apply a border to the cell that has the headers, as that would show a tilted line in the cell.
You can also use the below formula to do the same, where the formula will return the cell content, and then you need to tilt it using the same steps covered above.
= "Month" & char ( 10 ) & Rept ( Char ( 8213 ) , 6 ) & char ( 10 ) & "Store"
Drawing a Diagonal Line and Adding the Text
Another good workaround to split the cell diagonally is to manually draw a line and add it to the cell.
Suppose I have the same dataset and I want to have both the headers in cell A1 with a split diagonal line separating both headings.
Here is how to do this:
- In cell A1, enter the text Month
- With the cell in the Edit mode, hold the ALT key and press the Enter key (or Option + Enter if using Mac)
- Repeat step 2 a couple of times 2 or 3 more times (to get more distance between the cursor and the word 'Month')
- Enter the text Store. This would give you a cell as shown below (with two headings and a gap in between)
- Click the Insert option in the menu
- Click on Drawing
- In the Drawing dialog box that opens, click on the 'Line' option
- Draw a diagonal line
- Click on Save and Close. This will insert the line in the worksheet
- Resize the line and place it within the cell A1
- Adjust the position of the word Month in the cell by adding a few spaces before it
This method gives a better-looking result as compared to the previous tilt method.
But there is one drawback of this method.
The line that we have inserted is not a part of the cell but an object that sits over the worksheet. While we have resized the line to make it fit within the cell, in case you resize the cell or you hide the column or filter it, this diagonal line would not follow the cell (i.e., it would not get resized or hidden with the cell)
A better workaround could be to use the image function and insert the image of a diagonal line within the cell.
Inserting Just the Diagonal Line in a Blank Cell
If all you want to do is insert a diagonal line within the cell in Google Sheets, there is an amazing sparkline chart technique that you can use.
Enter the below formula in the cell where you want the diagonal line, and you would get that as the result.
=Sparkline({1,0},{"color","black"})
The above formula creates a sparkline line chart with the cell with two data points, 1 and 0. This is why you get a diagonal line within the cell.
In case you want the diagonal in the other direction, use the below formula:
=Sparkline({0,1},{"color","black"})
Since we are using the sparkline chart, you would not be able to enter any data or use any formula to combine text with the sparkline chart formula.
The good thing about this method is that the line would stick with the self. So, if you hide the cell or filter the cell then because the line is apart of the cell it would follow the suit.
These are some of the methods that you can use to split a cell by inserting a diagonal line in Google Sheets.
I hope you found this tutorial useful.
Other Google Sheets tutorials you may like:
- How to Insert Text Box in Google Sheets
- How to Change Text Case in Google Sheets (Upper, Lower, or Proper)
- How to Wrap Text In Google Sheets (with a single click)
- How to Indent Text in Google Sheets
Related posts:
Google Docs How to Draw 45 Degree Line on Graph
Source: https://spreadsheetpoint.com/insert-diagonal-line-google-sheets/
0 Response to "Google Docs How to Draw 45 Degree Line on Graph"
Post a Comment