Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Column Width

Hi Guys !!

I want to learn auto column width VBA application. When I enter data
in the column, column width should adjust according to size of DATA.
Can somebody help ! I will appreciate your efforts. Thanks in
advance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Column Width

Hi

This is an event code, so it has to be inserted into the codesheet for the
desired sheet. Also, the column width will never be less than 8:

Private Sub Worksheet_Change(ByVal Target As Range)
Target.EntireColumn.AutoFit
If Target.ColumnWidth < 8 Then
Target.ColumnWidth = 8
End If
End Sub

Regards,
Per

"Khan" skrev i meddelelsen
...
Hi Guys !!

I want to learn auto column width VBA application. When I enter data
in the column, column width should adjust according to size of DATA.
Can somebody help ! I will appreciate your efforts. Thanks in
advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Column Width

Hi,

Alt+F11 to open VB editor. Double click the worksheet you want this on and
paste the code below in

Private Sub Worksheet_Change(ByVal Target As Range)
Columns(Target.Column).EntireColumn.AutoFit
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Khan" wrote:

Hi Guys !!

I want to learn auto column width VBA application. When I enter data
in the column, column width should adjust according to size of DATA.
Can somebody help ! I will appreciate your efforts. Thanks in
advance.

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Column Width

On May 1, 12:47*pm, Mike H wrote:
Hi,

Alt+F11 to open VB editor. Double click the worksheet you want this on and
paste the code below in

Private Sub Worksheet_Change(ByVal Target As Range)
Columns(Target.Column).EntireColumn.AutoFit
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.



"Khan" wrote:
Hi Guys !!


I want to learn auto column width VBA application. When I enter data
in the column, column width should adjust according to size of DATA.
Can somebody help ! *I will appreciate your efforts. Thanks in
advance.


.- Hide quoted text -


- Show quoted text -


Dear Mike,

Thank you very much for this great help !

Khan
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
Change Cell Width WITHOUT changing Column width dww701 Excel Discussion (Misc queries) 1 January 12th 09 10:52 PM
Create a macro which takes a column name and width and sets the column width to what it should be Ag Excel Programming 4 September 29th 07 11:29 PM
How to make cell width different than the column width it lies in John Excel Discussion (Misc queries) 2 September 11th 06 10:41 PM
Set Column Width Based On Total Width Of Other Columns rayneraingoaway Excel Programming 1 June 28th 06 11:10 PM


All times are GMT +1. The time now is 06:45 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"