AutoFit method of Range class failed

From: Wellie (anonymous_at_discussions.microsoft.com)
Date: 02/29/04


Date: Sun, 29 Feb 2004 05:14:45 -0800

The following are the simple few lines of code to adjust
the height of rows when user clicks the "Adjust Rows"
button. I keep on getting a run-time error "1004" saying
AutFit method of Range class failed.

Can someone please tell me where it fails ?

PS: The column contains data need adjust is Column D with
with more than 999 rows of data.

Private sub Adjust_Rows_Click()
Dim Rows as Integer

     Rows = ActiveSheet.Range("D999").End(xlUp).Row
     ActiveSheet.Range("D4:D"+Cstr(Rows)).Rows.AutoFit
End Sub

Thanks in advance for any help.



Relevant Pages

  • Re: Creating a Macro to adjust the row heights
    ... Because your workbook might not open to the sheet you want to adjust. ... Private Sub Workbook_Open ... Dim lr As Long, rng As Range, sh As Worksheet ...
    (microsoft.public.excel.programming)
  • Re: ADDING A TIMESTAMP
    ... Private Sub TextBoxName_AfterUpdate ... it to adjust the current time. ... > in a memo field and when I hit enter it inserts a ... > timestamp / ...
    (microsoft.public.access.gettingstarted)
  • Re: edit combo boxes
    ... then show that control toolbox toolbar. ... Select one of the comboboxes. ... This may be the thing you need to adjust. ... Private Sub ComboBox1_MouseDown(ByVal Button As Integer, ...
    (microsoft.public.excel.programming)
  • Re: Automatic date or time in forms
    ... When I use this option users can not adjust this cell. ... Marjan ... "Tom Ogilvy" wrote: ... > Private Sub Userform_Activate ...
    (microsoft.public.excel.programming)
  • Re: Send Only The Active Sheet you are on as an Attachment
    ... Any way to adjust this code so that they could pick the names of who to ... Private Sub CmdSendActive_Click ... Dim strdate As String ... SendMail TxtEmail_Name, _ ...
    (microsoft.public.excel)