How to get line feed into axis label?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,676
Office Version
  1. 365
Platform
  1. Windows
Now I need to know how to get Excel to accept a linefeed character in a text expression.

In this table, E7:E11 have a texst string that is generated from the two cells to the left. The result is a single line.

Book1 (version 1).xlsb
BCDEFGHI
5DatesAverage mg/dL
6StartEndDaysX AxisAMPMInsulinVictoza
76/10/20 8/31/20 828/31/20 (82)15321656
88/11/20 10/27/20 7710/27/20 (77)153207451.12
910/12/20 2/02/21 1132/02/21 (113)163207451.72
101/20/21 2/20/21 312/20/21 (31)159213451.80
112/20/21 3/07/21 153/07/21 (15)159228461.80
12
138/31/20 (82)
1410/27/20 (77)
152/02/21 (113)
162/20/21 (31)
173/07/21 (15)
Sheet1
Cell Formulas
RangeFormula
D7:D11D7=C7-B7
E7:E11E7=TEXT(C7,"m/dd/yy") & " (" & D7 & ")"


If I create a chart using this data, I get:

1633838688274.png


But I would like the x-axis labels to look like the data in E13:E17. To get it, I copied the values above and then manually inserted a linefeed (Alt+Enter). I cannot figure out how to get that linefeed into the expression so that E7:E11 look like E13:E17. That gives me this chart, which is what I want.

1633839079371.png


Is there a way to enter code for a linefeed in that expression? I do it in VBA using vbCrLf, but if I put that in the expression, I get a #NAME error.

Thanks
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Try
Excel Formula:
=TEXT(C7,"m/dd/yy")&CHAR(10)&" (" & D7 & ")"
I tried that. Here it is again:
Book1 (version 1).xlsb
BCDEFGHI
5DatesAverage mg/dL
6StartEndDaysX AxisAMPMInsulinVictoza
76/10/20 8/31/20 828/31/20 (82)15321656
88/11/20 10/27/20 7710/27/20 (77)153207451.12
910/12/20 2/02/21 1132/02/21 (113)163207451.72
101/20/21 2/20/21 312/20/21 (31)159213451.80
112/20/21 3/07/21 153/07/21 (15)159228461.80
Sheet1
Cell Formulas
RangeFormula
D7:D11D7=C7-B7
E7:E11E7=TEXT(C7,"m/dd/yy") & CHAR(10) & " (" & D7 &")"


Huh? In the mini-sheet above, it looks like the linefeed worked. But in my sheet, it looks like this:

1633842712068.png


I'm not sure why that column in the mioni-sheet is right-justified. In the sheet, it is centered. And if I generate a chart using that column, it shows up as 2 lines:

1633842848468.png


So I have what I wanted, but I would like to know why it doesn't show as 2 lines in the cell. It is formatted as General. Changing it to Text did not make any difference. (sigh)
 
Upvote 0
Try enabling Wrap Text in the cell.
Bingo! Can I give you two solutions on the same thread? (y)(y)? Thanks. I should have known that one. :cry:

PS: This is great. I can have my cake and eat it, too. If I turn wrap off, the table is more compact, buit the chart is correct. :giggle:
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,432
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top