column width

H

Hazel

I have created a spreadsheet where every column has a different width. After
adjusting the width, I saved it. Every time I sort the spreadsheet, the
column width changes at will and I have to go through and adjust them again.
There is no pattern to it. They just change at random. What can I do to get
my adjustments to take?
 
J

JMay

Such as (?)...

Private Sub Worksheet_Activate()
Me.Columns("A:C").ColumnWidth = 10
Me.Columns("D").ColumnWidth = 5
Me.Columns("E").ColumnWidth = 25
Me.Columns("F").ColumnWidth = 50
Me.Columns("G:L").ColumnWidth = 3
End Sub

HTH
 
H

Hazel

Jay--I appreciate your response (this is really driving me crazy!) But I
don't understand it.
 
S

Satti Charvak

Hi Hazel,
That was basically a macro.

now, if you don't know anhthing about macro's...i'll give you some idea to
use them.

open the excel sheet

now hit ALT+F11 (Function key f-11)

now on the left side you would see 3 worksheets ,
select a sheet where you want the code now after you select a sheet by
double clicking. Now after that you would see some are appearing on the right.

This is the place where you paste the code.

you can run the code by using the F5 key this time. and the code will
anyways runs everytime the worksheet is selected.

also regarding the code,

the line

Me.Columns("A:C").ColumnWidth = 10

mean to select columns a to c and set there width to 10 points.

the line

Me.Columns("D").ColumnWidth = 5

means to select only column d and set it's width to 5 point


alos, one important thing. please go to macro security and enable the macros
otherwise the code wouldnot run.
 

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