Cell Width

K

KB

I need cells to automatically adjust to fit text entered.
This text will be entered by others after I complete the workbook.

Thanks for your help!
 
G

Gord Dibben

Format>Column>Autofit Selection for width.

Format>Row>Autofit for height.

Note you can also turn on wordwrap.

Entire rows and entire columns will adjust.

You cannot adjust individual cells.


Gord Dibben MS Excel MVP
 
K

KB

I tried it and it adjusted the column width to what is already on the
worksheet, but did not adjust as I entered in new information.
 
R

Rick Rothstein

Are you talking about this functionality for every cell on the worksheet? If
so, right click the tab at the bottom of the worksheet, select View Code
from the popup menu and copy paste the code below into the code window that
appeared...

'************* START OF CODE *************
Dim LastColumn As Long

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If LastColumn > 0 Then
Application.ScreenUpdating = False
Columns(LastColumn).AutoFit
Application.ScreenUpdating = True
End If
LastColumn = Target.Column
End Sub
'************* END OF CODE *************

If you do not want this functionality for the whole sheet, then tell us for
what cells you do want it for.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top