Automatically adjusting columns

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have Excel 2003.

I have a worksheet with 11 columns. I need to adjust the column width of
each column so that all data will be shown. I know that I can do this
adjustment by double clicking on each column's border, but that means 11
double clicks; I would like to adjust all of the columns with a single
action. Is this possible?

Thank you.
 
Select all 11 columns first. Then they'all all react to that double click.

And you could throw caution to the wind and select all the cells and adjust all
of the non-empty columns at once!
 
Select the 11 columns by dragging the mouse pointer across the headers.

Double-click on any column.


Gord Dibben MS Excel MVP
 
Alright, follow these instructions...

Go to

Tools--> Macro --> VBE (Visual Basic Editor)

Look to your left, you will see something called the Project Explorer. It
will have a tree setup that says VBAProject then whatever the name of your
workbook is.

Open up your workbook in this Project Explorer...
Double click on the Sheet that you want the auto fit.
A module should open up.

On top of that module you will see a drop down box with the word "general"
in it.
Change that to Worksheet.

When you change it this should show up.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub

If you see this copy and paste this code in between those two lines...

Columns("A:H").EntireColumn.AutoFit

Change, A or H to whatever columns you need changed. What A:H means is that
A,B,C,D,E,F,G,H has AutoFit in it.

Then whenever you do anything on that worksheet it will automatically
autofit the columns for you. LMK if this works.
 
Oh yea, I forgot... if you are just doing this once you can just highlight
all 11 columns and double click on just one of them... and it will autofit
all 11. Lol, should of went with that one first.
 
Thanks, Dave.

Dave Peterson said:
Select all 11 columns first. Then they'all all react to that double click.

And you could throw caution to the wind and select all the cells and adjust all
of the non-empty columns at once!
 
Thank you very much, Gord.

Gord Dibben said:
Select the 11 columns by dragging the mouse pointer across the headers.

Double-click on any column.


Gord Dibben MS Excel MVP
 
Thank you, AKphidelt. I am doing the column change only once, so I will go
with the highlighting and double-clicking. However, I appreciate your
instructions regarding the Project Explorer. It represents a permanent
solution, and I am going to learn it.
 

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

Back
Top