Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Excel AutoFit question


  • Please log in to reply

#1
hulud

hulud

    Member

  • Member
  • PipPipPip
  • 268 posts
i am having issues with a report in excel.

the formatting of the sheet makes it so some of the columns do not display all of the data (ie not autofitted) and the sheet contains 31 pages. is there a way to set by default all columns to always auto-fit in excel... or do i have to select each column on each sheet and go to format -> column -> autofit.

thx :whistling:
  • 0

Advertisements


#2
dsenette

dsenette

    Je suis Napoléon!

  • Community Leader
  • 26,047 posts
  • MVP
you don't have to select EACH collum...you can just click the square in the top left corner (the grey square near the column numbers) then do the format autofit....you may need to do this for each sheet...but you could try this

click on the first sheet...then hold the ctrl button...then while holding it...click on each other sheet in the book...THEN on the first sheet do as above (with the top left corner deal) and try it that way
  • 0

#3
dsm

dsm

    Member

  • Member
  • PipPip
  • 98 posts
hulud,
the advice from dsenette will work fine.

If this is a task that you have to perform frequently with incoming reports you can also create a macro to automate these steps. I have provided example code below.

Sub MacAutofitAllSheets()
'
Dim S As Integer 'worksheet loop counter
Dim C As Integer 'total worksheet count
Dim Dummy As Variant

C = Worksheets.Count

For S = 1 To C 'loop through all worksheets
Sheets(S).Select
Cells.Select
Selection.ColumnWidth = 2# 'set column width >>> 2
Cells.EntireColumn.AutoFit 'set column width >>> best fit
Range("A1").Select
Next S

Sheets(1).Select
Range("A1").Select

Dummy = MsgBox("finished", vbOKOnly) 'send message when finished

End Sub





regards
dsm
  • 0

#4
dsenette

dsenette

    Je suis Napoléon!

  • Community Leader
  • 26,047 posts
  • MVP
that's a great macro dsm...i've never been good with excell macros
  • 0

#5
hulud

hulud

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 268 posts
thanks very much for your answers guys. the first piece of advice worked, i will try to figure out how to use the macros
  • 0

#6
dsm

dsm

    Member

  • Member
  • PipPip
  • 98 posts
hulud,
I have attached a few links that may help explain macro creation steps

http://www.anthony-v...a/vbabasic1.htm

http://www.mrexcel.com/tip038.shtml
http://www.mvps.org/.../getstarted.htm
http://www.exceltip...._Excel/631.html
http://www.fontstuff...ba/vbatut03.htm


regards
dsm
  • 0

#7
hulud

hulud

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 268 posts
thanks again. ill take a look
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP