Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default find largest column width and ...

Hello

i would like to find the largest column width in a range e.g. "A1:A20" and then set all the columns of this range to this largest width. how can i do that?

Thanx.


Submitted via EggHeadCafe - Software Developer Portal of Choice
Crypto Obfuscator for .NET - Product Review
http://www.eggheadcafe.com/tutorials...or-for-ne.aspx
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default find largest column width and ...

Try some code like

Sub AAA()
Dim MaxWidth As Double
Dim R As Range
Dim RR As Range

Set RR = Range("A1:K10")
For Each R In RR
If R.ColumnWidth MaxWidth Then
MaxWidth = R.ColumnWidth
End If
Next R
RR.EntireColumn.ColumnWidth = MaxWidth
End Sub

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]



On Sat, 08 May 2010 06:47:51 -0700, S S wrote:

Hello

i would like to find the largest column width in a range e.g. "A1:A20" and then set all the columns of this range to this largest width. how can i do that?

Thanx.


Submitted via EggHeadCafe - Software Developer Portal of Choice
Crypto Obfuscator for .NET - Product Review
http://www.eggheadcafe.com/tutorials/aspnet/bf15c41b-6510-403e-9af8-f5fd987fafb1/crypto-obfuscator-for-ne.aspx

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default find largest column width and ...

Your posted range has only one column. For columns A-Z, try:

Sub demo()
Dim cw As Integer, i As Integer, wdth As Integer
cv = 0
For i = 1 To 26
wdth = Columns(i).ColumnWidth
If wdth cw Then
cw = wdth
End If
Next
Columns("A:Z").ColumnWidth = cw
End Sub

--
Gary''s Student - gsnu201002


"S S" wrote:

Hello

i would like to find the largest column width in a range e.g. "A1:A20" and then set all the columns of this range to this largest width. how can i do that?

Thanx.


Submitted via EggHeadCafe - Software Developer Portal of Choice
Crypto Obfuscator for .NET - Product Review
http://www.eggheadcafe.com/tutorials...or-for-ne.aspx
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default find largest column width and ...

Hello,
with Excel 2007 you can frame in the region and click:
Format
Autofit column width

Hth

Gabor Sebo





"S S" wrote in message ...
Hello

i would like to find the largest column width in a range e.g. "A1:A20" and
then set all the columns of this range to this largest width. how can i do
that?

Thanx.


Submitted via EggHeadCafe - Software Developer Portal of Choice
Crypto Obfuscator for .NET - Product Review
http://www.eggheadcafe.com/tutorials...or-for-ne.aspx



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default find largest column width and ...

How can you do that?

With great difficulty.

A1:A20 is a single column.


Gord Dibben MS Excel MVP

On Sat, 08 May 2010 06:47:51 -0700, S S wrote:

Hello

i would like to find the largest column width in a range e.g. "A1:A20" and then set all the columns of this range to this largest width. how can i do that?

Thanx.


Submitted via EggHeadCafe - Software Developer Portal of Choice
Crypto Obfuscator for .NET - Product Review
http://www.eggheadcafe.com/tutorials...or-for-ne.aspx


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
How to find the largest value in a column? needofhelp Excel Discussion (Misc queries) 2 December 28th 06 07:34 PM
find the largest value in column, put in a cell JcR Excel Worksheet Functions 1 May 22nd 06 01:11 AM
Find Largest and Return Column Name Tom321 Excel Worksheet Functions 2 March 17th 06 05:09 PM
find the largest value in column, put in a cell JcR Excel Discussion (Misc queries) 2 March 12th 06 10:56 PM
How do I find the largest in a column BigBuck98 Excel Worksheet Functions 5 January 10th 06 12:11 AM


All times are GMT +1. The time now is 02:58 PM.

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

About Us

"It's about Microsoft Excel"