+ Reply to Thread
Results 1 to 4 of 4

Method Range of object '_Global' failed

  1. #1
    Registered User
    Join Date
    08-25-2005
    Posts
    2

    Method Range of object '_Global' failed

    Hi ,
    I have been trying to autofill dates of the month for a particular sheet, but it throws me this error Method Range of object '_Global' failed.

    The following code snippet is what iam using

    'Fill in the Dates for the Month in the first column
    objExcelRep.Worksheets("DataMatrix").Cells(intCellIndexRow, 1) = Month(Date) & "/01/" & Year(Date)
    objExcelRep.Worksheets("DataMatrix").Cells(intCellIndexRow, 1).Select
    strRange = "A" & intCellIndexRow & ":A" & intCellIndexRow + MonthNoOfDays - 1
    Selection.AutoFill Destination:=Range(strRange), Type:=xlFillDays

    Am i missing something?

    Thanks,
    John

  2. #2
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    > Am i missing something?


    Yes.

    Probably the parent sheet for the Range in the last line.

    Selection.AutoFill Destination:=Worksheets("YOUR_SHEET_NAME").Range(strRange), Type:=xlFillDays

    Mangesh

  3. #3
    Registered User
    Join Date
    08-25-2005
    Posts
    2
    I tried this
    Range("A" & intCellIndexRow).AutoFill Destination:=objExcelRep1.Worksheets("DataMatrix").Range(strRange), Type:=xlFillDays

    and still it throws me the same "_global" error.

    Thanks,
    John

  4. #4
    Tom Ogilvy
    Guest

    Re: Method Range of object '_Global' failed

    this worked for me:

    Sub ABC()
    Set ObjExcelRep = ActiveWorkbook
    intCellIndexRow = 5
    MonthNoOfDays = Day(DateSerial( _
    Year(Date), Month(Date) + 1, 0))
    ObjExcelRep.Activate
    ObjExcelRep.Worksheets("DataMatrix").Select
    ObjExcelRep.Worksheets("DataMatrix") _
    .Cells(intCellIndexRow, 1) = Month(Date) & "/01/" _
    & Year(Date)
    ObjExcelRep.Worksheets("DataMatrix") _
    .Cells(intCellIndexRow, 1).Select
    strRange = "A" & intCellIndexRow & ":A" & _
    intCellIndexRow + MonthNoOfDays - 1
    Selection.AutoFill Destination:=Range(strRange), _
    Type:=xlFillDays


    End Sub

    --
    Regards,
    Tom Ogilvy

    "maverick2005" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > I tried this
    > Range("A" & intCellIndexRow).AutoFill
    > Destination:=objExcelRep1.Worksheets("DataMatrix").Range(strRange),
    > Type:=xlFillDays
    >
    > and still it throws me the same "_global" error.
    >
    > Thanks,
    > John
    >
    >
    > --
    > maverick2005
    > ------------------------------------------------------------------------
    > maverick2005's Profile:

    http://www.excelforum.com/member.php...o&userid=26627
    > View this thread: http://www.excelforum.com/showthread...hreadid=399026
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1