Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default EXCEL "EntireColumn.AutoFit" Help!

Can anyone recommend a good Excel group (for dummies!), or maybe my
question is a simple one (by the group's collective standards). I
frequently do Format/Column/AutoFit to get my columns to fit (expand
or shrink) to fit the contents in every column, and would like to be
able to have Excel do it automatically. Someone said I could use a
Worksheet Selection Change event, like this:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Columns("A:IV").EntireColumn.AutoFit
End Sub

I was clueless, but took a shot in the dark and with the file open,
opened up Visual Basic, inserted a Module, copied and pasted their
text, saved and closed. It WORKED! Well, it worked at WORK anyways,
and now that I'm trying it again at home, I can't get it to work at
all. This "dummy" needs some help please! Using Microsoft Excel 2000
in Windows 2000 at work and ME at home. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default EXCEL "EntireColumn.AutoFit" Help!

That code would only affect one worksheet in the workbook so it's not the
best answer. To have it work on all sheets in the workbook open the
"ThisWorkbook" module for the workbook in the VBE's Project window and paste
in this code:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Sh.Columns.AutoFit
End Sub


--
Jim Rech
Excel MVP


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default EXCEL "EntireColumn.AutoFit" Help!

See answer to your multipost of this question.

--
Regards,
Tom Ogilvy

Fred wrote in message
om...
Can anyone recommend a good Excel group (for dummies!), or maybe my
question is a simple one (by the group's collective standards). I
frequently do Format/Column/AutoFit to get my columns to fit (expand
or shrink) to fit the contents in every column, and would like to be
able to have Excel do it automatically. Someone said I could use a
Worksheet Selection Change event, like this:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Columns("A:IV").EntireColumn.AutoFit
End Sub

I was clueless, but took a shot in the dark and with the file open,
opened up Visual Basic, inserted a Module, copied and pasted their
text, saved and closed. It WORKED! Well, it worked at WORK anyways,
and now that I'm trying it again at home, I can't get it to work at
all. This "dummy" needs some help please! Using Microsoft Excel 2000
in Windows 2000 at work and ME at home. Thanks.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
"autofit row ht" in merged cells amy jo Excel Discussion (Misc queries) 2 March 14th 10 07:21 PM
Autofit (Columns.EntireColumn.AutoFit) does not work Michiel via OfficeKB.com Excel Discussion (Misc queries) 3 February 10th 09 05:29 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 06:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"