“EntireColumn.AutoFit” Help!

F

FredL

I frequently do Format/Column/AutoFit to get my columns to fit (expand
or shrink) to fit the contents in every column, and would like to be
able to have Excel do it automatically. Someone said I could use a
Worksheet Selection Change event, like this:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Columns("A:IV").EntireColumn.AutoFit
End Sub

I was clueless, but took a shot in the dark and with the file open,
opened up Visual Basic, inserted a Module, copied and pasted their
text, saved and closed. It WORKED! Well, it worked at WORK anyways,
and now that I’m trying it again at HOME, I can’t get it to work at
all. This “dummy” needs some help please! Using Microsoft Excel 2000
in Windows 2000 at work and ME at home. Thanks.
 
P

Peo Sjoblom

Right click the sheet tab where you want this, select view code,
paste it into the window that opens
 
T

Tim Otero

Hi Fred,

Could be your Macro Security setting is set too high. Goto
Tools|Macro|Security, select "Medium" and hit OK.

tim
 
P

Peo Sjoblom

Tim,

OTOH since the OP is using an event macro I can't see that it would work
putting it into a module
so I can't understand how it could work at work.

--

Regards,

Peo Sjoblom

Tim Otero said:
Hi Fred,

Could be your Macro Security setting is set too high. Goto
Tools|Macro|Security, select "Medium" and hit OK.

tim
 
T

Tim Otero

Peo,

I hear ya...maybe his office is in the twilight zone. <vbg>

tim

Peo Sjoblom said:
Tim,

OTOH since the OP is using an event macro I can't see that it would work
putting it into a module
so I can't understand how it could work at work.
 

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