find largest column width and ...

  • Thread starter Thread starter S S
  • Start date Start date
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]
 
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
 
How can you do that?

With great difficulty.

A1:A20 is a single column.


Gord Dibben MS Excel MVP
 
Back
Top