Written by Allen Wyatt (last updated August 7, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365
Stephen has a worksheet that has a row for each movie in his collection—over a thousand of them. One of the columns in the worksheet contains the synopsis of each movie. The column is narrow enough that only the first three (or so) words show. Making it wider makes the data less usable, and making it wide enough for the entire synopsis is untenable. Stephen wonders if there is a way he can leave the column narrow and when he clicks on a synopsis it appears, in full length, in a box of some sort.
There are several different ways you can approach this problem. The first possibility is simple—just expand the Formula bar so that it occupies multiple lines. Then, when you select the cell containing the synopsis, you'll see it displayed in the expanded Formula bar. To expand your Formula bar, check out this tip:
https://excelribbon.tips.net/T011705
Another simple approach is to simply double-click on the cell that contains the synopsis. Excel should enlarge the cell so you can see everything it contains. This occurs only if you have Excel configured to allow in-cell editing, however. If you double-click on a cell and cannot see the enlargement to which I referred, you will find this tip helpful:
https://excelribbon.tips.net/T009308
Another very simple approach is to look at how your worksheet is structured. You can move the synopsis column so it is the rightmost column in your data, and then the contents of each synopsis cell will "spill over" into the empty cells to the right. This can allow you to see quite a bit of each synopsis without the need to change how anything is displayed. If desired, you could also widen the right-most column and turn on text wrapping in the cells.
The final non-macro approach is to rely on what Microsoft calls "data forms." These allow you to treat each row in a data table as a record and display that record in a dialog box. You can find information about data forms in this tip:
https://excelribbon.tips.net/T006207
Another good source for information about data forms can be found on the Microsoft web page at this ridiculously long URL:
https://support.office.com/en-us/article/add-edit-find-and-delete-rows-by-using-a-data-form-17bca0a4-3ba5-444a-983c-a8ce70609374
If you want a macro-based approach, you can set up an event handler that will display the cell information in a message box. Right-click on the worksheet tab and, from the resulting Context menu, choose View Code. This displays the Visual Basic Editor, into which you can paste the following macro:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) Dim sTemp As String If Target.Cells.Count = 1 Then sTemp = Target.Text MsgBox sTemp, , "Cell Contents" Else MsgBox "Please select only one cell" End If Cancel = True End Sub
With this macro in place, anytime you right-click on a cell, the contents of the cell are displayed in a message box. If you want the usual Context menu displayed when you right-click on a cell, then remove the last line of the macro (Cancel = True). Once you click OK in the message box, the right-click Context menu is displayed.
If you prefer, you could copy the contents of the synopsis cells to comments attached to each of the cells. All you would have to do is to select all the synopsis cells and then run the following macro:
Sub AddCommentsToCells() Dim c As Range On Error Resume Next For Each c In Selection.Cells If Not IsEmpty(c) Then c.AddComment c.Comment.Visible = 0 c.Comment.Text Text:=c.Formula End If Next End Sub
When you hover the mouse pointer over one of the synopsis cells, the comment attached to that cell springs into view, showing you the full synopsis.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13894) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365.
Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!
Need to change some cell references in your defined names? Changing one or two is easy; changing dozens is a good deal ...
Discover MoreExcel allows you to reference data in other workbooks by establishing links to that data. If you later want to get rid of ...
Discover MoreDelete a cell or a range of cells, and Excel needs to figure out how to rearrange the void left by the deletion. You can ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2021-08-08 11:55:50
J. Woolley
Since Excel 2007, a cell can accommodate 32,767 characters. The Tip's 1st VBA method uses a MsgBox, which will truncate the synopsis at 1,024 characters. Its 2nd VBA method uses an Unthreaded Comment (now called Note), which apparently can accommodate all the characters in a cell; but the Comment will usually need to be resized to display a synopsis with more than about 100 characters. (Also, c.Formula should be changed to c.Value in that macro.)
A method that does not suffer these limitations follows. This method assumes all sysnopsis cells are in column C (the 3rd column), but that can be adjusted. When you select (left-click) a synopsis cell, all of its contents will appear in a TextBox. When you select a different cell or close the workbook, that TextBox will be deleted.
Right-click on the worksheet's tab and pick View Code, then put this VBA in the worksheet's Sheet module:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const TheCol = 3 ' for synopsis in column C (adjust as necessary)
Const FirstRow = 2 ' no synopsis before row 2 (adjust...)
DeleteBox
With Target
If .Column = TheCol And .Row >= FirstRow And .Cells.Count = 1 _
And Not IsError(.Value) Then Call MakeBox(Target)
End With
End Sub
Put this VBA in the workbook’s ThisWorkbook module:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim Saved As Boolean
Saved = Me.Saved ' previous status
DeleteBox ' possible status change
If Saved Then Me.Save ' restore status
End Sub
Right-click the VBAProject and pick Insert > Module to add a standard module (like Module1), then include this VBA:
Private TheBox As Shape
Sub MakeBox(Target As Range)
Const BoxWidth = 200, BoxHeight = 10 ' adjust if desired
With Target
Set TheBox = ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, _
.Offset(0, 1).Left, .Offset(0, 1).Top, BoxWidth, BoxHeight)
With TheBox.TextFrame2
.AutoSize = msoAutoSizeShapeToFitText
.WordWrap = True
.TextRange.Text = Target.Value
End With
End With
End Sub
Sub DeleteBox()
If Not (TheBox Is Nothing) Then
TheBox.Delete
Set TheBox = Nothing
End If
End Sub
2021-08-08 01:23:32
Roy
There's one other thing one could do and that is to expand the formula editor in which one may view contents.
Usually one would think of it in the context of reading or constructing a long formula, but it can allow one to examine long text just as easily.
We are used to clicking the expansion arrow for it and getting three lines. Good for ABOUT 154 capital letters per line if doing the alphabet and standardizing to all M's, 133. So in the context of average text with lots of non-capitals, some periods, some commas... maybe 160-180 per line? So perhaps 500-ish characters per expanded view.
For 2,000-3,000 you'd need more, or to abandon the thought..
But you can have more! You can expand the formula editor to however many lines your screen allows. You can set your expanded view to do this and read a cell normally, in the one-line formula editor for most of the movie titles, or your own text, and click to expand when it runs past the single line's ability getting the, say, 20 line expanded formula editor. Probably overkill for most, but should likely do nicely for the most extreme.
If 't'were me, I'd probably approach that one with, say 10 lines, and hand expand for the very longest ones, then back to 10-ish lines to keep going. Of course, clicking to un-expand after each one if I found 10 or so too obnoxious for the viewing I were doing. Best of all worlds, handles maybe 30-35 lines on a landscape 24 inch monitor, so call it 5,000+ characters that can be viewed at once.
So, how?
Firstly, expand it, so this only takes place when expanded, not when you want the single line. (or don't, so it's always expanded and adjust to suit as desired).
To do it, hover your mouse over it and slowly move down. As it reaches the bottom of the white formula bar region, and begins to go overtop the gray that is above the column headings (the column heading divisions only extend partly up to the white region so you could think of it as the hovering mouse reaching the gray bar above the headings, but it's truly just a roof, so to speak), the mouse will suddenly turn into a version of the up/down two-headed arrow one associates with MS's border moving indicator (especially that of Word, though rather different, so "associates with").
That's lost just as suddenly, so it's a wee bit fiddly, but when you have it (and that happens when its top head is 1-2mm from the border), you can click down and drag the border downward, or upward, as many rows as you wish. Want 25 lines for viewing your formula? Nice when using LET() and a formal structuring and I bet even nicer when LAMBDA reaches us hoi polloi. Also great for formal structure to enhance one's use of IFS() and related things, even IF() if one has nested many of them.
It sticks, so if you want to return to the standard three line expanded view, you have to do it by hand. If you've a pranky mind, expand a co-worker's formula editor and pull it up to one line, then un-expand. He'll never figure out why he never can get the expanded three lines.
I came across it a couple years back very much by accident and didn't realize it had happened, just thought Excel had listened (for once) and expanded it in the monthly upgrade. Later I saw the two-headed border arrow and experimented. Mentioned it on a website and found the Excel MVP's had known about it for decades and never thought anyone did not know about it.
It's been hugely helpful to me, especially the way I like to give my LET()'s a formal structure to make parsing them later easier. Also led me to put the changeable portions of them on the first line (usually... or two) so the changeable pieces are right at the beginning for a user to find quickly. So it improved my technique just by existing and being known.
Again, no help to those who want them to un-expand automatically, but perhaps of interest to those who'd like to have the use of it.
In Stephen's case here, he'd be well-served to keep it unexpanded for normal titles, then expand to the 10-line or so expanded view for most that go longer. Read his title, do whatever, un-expand it back to a single line and roll on. If it doesn't read fully in the expanded editor, he can scroll another screen of it to read more, or just increase the size of the editor. After finishing, he could run it back up to his standard, say the 10 lines, un-expand, and continue on.
No macros, if they are not desired. Down arrow if it would have encouraged him to learn how to use the forms Mr. Wyatt brought up, but that's a small cost in this case, I think anyway. But with this, think of all the other uses one could have for it. So that could make up for the down tick.
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments