PC Review


Reply
Thread Tools Rate Thread

AutoFit macro that will not affect the header row?

 
 
StargateFanNotAtHome
Guest
Posts: n/a
 
      17th Jul 2008
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! D
(XL2003)

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      17th Jul 2008
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



StargateFanNotAtHome wrote:
>
> 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! D
> (XL2003)


--

Dave Peterson
 
Reply With Quote
 
StargateFanNotAtHome
Guest
Posts: n/a
 
      17th Jul 2008
On Wed, 16 Jul 2008 20:02:26 -0500, Dave Peterson
<(E-Mail Removed)> wrote:

>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. D

>StargateFanNotAtHome wrote:
>>
>> 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! D
>> (XL2003)

>
>--
>
>Dave Peterson


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to affect all sheets REMB Microsoft Excel Misc 3 4th Jun 2010 09:45 PM
Autofit custom header top margin to text size Breck Microsoft Excel Programming 0 3rd Feb 2009 03:52 AM
How do I stop Macro from affect other Workbooks =?Utf-8?B?QiBCYWdnaW5z?= Microsoft Excel Programming 2 23rd Nov 2006 09:09 AM
macro / autofit =?Utf-8?B?Sm9uYXRoYW4gQ29vcGVy?= Microsoft Excel Misc 5 9th Jan 2006 01:24 PM
Header to affect every detail item Cathy Microsoft Access Form Coding 2 11th Apr 2004 02:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:48 AM.