ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   find largest column width and ... (https://www.excelbanter.com/excel-programming/442405-find-largest-column-width.html)

S S[_2_]

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

Chip Pearson

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


Gary''s Student

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
.


helene and gabor

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




Gord Dibben

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




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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com