Column width

A

André

So i have my data validation working, now is there a way
to have the columns automaticly adjust to the right width
depending on the data that is selected for the cell?

A.
 
I

igorek

try this

Sub colsize()

Columns("a:iv").Select
Columns("a:iv").EntireColumn.AutoFit
Range("a1").Select

End Sub
 
A

André

Can i have this macro run automaticly either when the
spreadsheet is opened or closed?

A.
 
J

J.E. McGimpsey

One way:

Put this in the ThisWorkbook code module:

Public Sub Workbook_Open()
Cells.EntireColumn.AutoFit
End Sub

Note that there's no need to select the columns.
 

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

Top