AutoFit macro that will not affect the header row?

  • Thread starter Thread starter StargateFanNotAtHome
  • Start date Start date
S

StargateFanNotAtHome

I've tried:
Selection.Rows.AutoFit
and
ActiveSheet.Rows.AutoFit

Selection.Rows.AutoFit only affects the active row one is on, which is
not enough. But the ActiveSheet one affects the entire sheet, which
would be okay if there were no header row.

Is there a way to get the macro fine-tuned to ignore the header row,
by any chance?

Thanks! :oD
(XL2003)
 
Selection.rows.autofit
will work on all the rows in the current selection. Not just the row with the
activecell. So you could select multiple rows before you run that code.

If you want to autofit rows 2 to whatever, you could use:

with activesheet
.rows("2:" & .rows.count).autofit
end with
 
Selection.rows.autofit
will work on all the rows in the current selection. Not just the row with the
activecell. So you could select multiple rows before you run that code.

If you want to autofit rows 2 to whatever, you could use:

with activesheet
.rows("2:" & .rows.count).autofit
end with

<sigh> Perfect! Thank you so much.

Another piece of code to add to my Tips folder, too! <g>

Thanks and cheers. :oD
 

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

Back
Top