find largest column width and ...

C

Chip Pearson

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]
 
G

Gary''s Student

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
 
G

Gord Dibben

How can you do that?

With great difficulty.

A1:A20 is a single column.


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top