ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   automatical cell size adjusting (https://www.excelbanter.com/excel-discussion-misc-queries/184524-automatical-cell-size-adjusting.html)

ninjaneer

automatical cell size adjusting
 
Hi
I've been using excel for a while now, and something that would be really
nice is to have cells resize themselves when word wrap is active, so that you
can just type away and be sure that the cell will stretch himself to display
all the text that you have just typed.

Is there anyone who knows of a way to do this?

Thanks a lot in advance!
Pieka

Gary''s Student

automatical cell size adjusting
 
If you want the cells to auto-expand after data is typed into them, then
enter this worksheet event macro in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Application.EnableEvents = False
Columns(t.Column).EntireColumn.AutoFit
Application.EnableEvents = True
End Sub


Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200781


"ninjaneer" wrote:

Hi
I've been using excel for a while now, and something that would be really
nice is to have cells resize themselves when word wrap is active, so that you
can just type away and be sure that the cell will stretch himself to display
all the text that you have just typed.

Is there anyone who knows of a way to do this?

Thanks a lot in advance!
Pieka


ninjaneer

automatical cell size adjusting
 
Wow, thanks. That's really cool.
Is there a way to get the cells to adjust row height rather than column
width, though?

Pieka

"Gary''s Student" wrote:

If you want the cells to auto-expand after data is typed into them, then
enter this worksheet event macro in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Application.EnableEvents = False
Columns(t.Column).EntireColumn.AutoFit
Application.EnableEvents = True
End Sub


Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200781


"ninjaneer" wrote:

Hi
I've been using excel for a while now, and something that would be really
nice is to have cells resize themselves when word wrap is active, so that you
can just type away and be sure that the cell will stretch himself to display
all the text that you have just typed.

Is there anyone who knows of a way to do this?

Thanks a lot in advance!
Pieka


Gary''s Student

automatical cell size adjusting
 
Try this instead of the other code:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Application.EnableEvents = False
Rows(t.Row).EntireRow.AutoFit
Application.EnableEvents = True
End Sub


--
Gary''s Student - gsnu200781


"ninjaneer" wrote:

Wow, thanks. That's really cool.
Is there a way to get the cells to adjust row height rather than column
width, though?

Pieka

"Gary''s Student" wrote:

If you want the cells to auto-expand after data is typed into them, then
enter this worksheet event macro in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Application.EnableEvents = False
Columns(t.Column).EntireColumn.AutoFit
Application.EnableEvents = True
End Sub


Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200781


"ninjaneer" wrote:

Hi
I've been using excel for a while now, and something that would be really
nice is to have cells resize themselves when word wrap is active, so that you
can just type away and be sure that the cell will stretch himself to display
all the text that you have just typed.

Is there anyone who knows of a way to do this?

Thanks a lot in advance!
Pieka


Dave Peterson

automatical cell size adjusting
 
You could use:
t.EntireRow.AutoFit

or
Target.entirerow.autofit

And drop the undeclared(!) variable <vbg.

Gary''s Student wrote:

Try this instead of the other code:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Application.EnableEvents = False
Rows(t.Row).EntireRow.AutoFit
Application.EnableEvents = True
End Sub

--
Gary''s Student - gsnu200781

"ninjaneer" wrote:

Wow, thanks. That's really cool.
Is there a way to get the cells to adjust row height rather than column
width, though?

Pieka

"Gary''s Student" wrote:

If you want the cells to auto-expand after data is typed into them, then
enter this worksheet event macro in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Application.EnableEvents = False
Columns(t.Column).EntireColumn.AutoFit
Application.EnableEvents = True
End Sub


Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200781


"ninjaneer" wrote:

Hi
I've been using excel for a while now, and something that would be really
nice is to have cells resize themselves when word wrap is active, so that you
can just type away and be sure that the cell will stretch himself to display
all the text that you have just typed.

Is there anyone who knows of a way to do this?

Thanks a lot in advance!
Pieka


--

Dave Peterson


All times are GMT +1. The time now is 03:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com