Method Range of object '_Global' failed

M

maverick2005

Hi ,
I have been trying to autofill dates of the month for
particular sheet, but it throws me this error Method Range of objec
'_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,
Joh
 
M

mangesh_yadav

Am i missing something?


Yes.

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

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

Manges
 
M

maverick2005

I tried this
Range("A" & intCellIndexRow).AutoFil
Destination:=objExcelRep1.Worksheets("DataMatrix").Range(strRange)
Type:=xlFillDays

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

Thanks,
Joh
 
T

Tom Ogilvy

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

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