View Full Version : Solved: Range object acting up in 2007

01-08-2013, 08:41 PM
Anyone know why this would fail in Excel 2007?Range(Cells(53,6), Cells(53,106)).Interior.Color = 0 I get "Method range of object worksheet failed".

A much smaller column argument in the second Cells property will avoid the error, as will different syntax, but I'm curious what's going on here to throw an error. Doesn't look like it should.

Kenneth Hobs
01-08-2013, 09:20 PM
Works fine for me in 2010 on Vista64. It will error 1004 if any of those cells are locked and the sheet is protected.

01-09-2013, 04:05 AM
Neither range nor cells is qualified so you're depending on defaults, which in turn depends on where the code is situated and/or what the activesheet is at the time.
For example, I wouls expect the code to fail if the code were in a userform's code module and a chart sheet was active at the time.
So, predictablty, the questions arise:
1.Where is the code?
2.What kind of sheet is active at the time?

01-09-2013, 06:50 AM
Sounds like a good point. I have the code in a worksheet and nested in a with block something like:Set wsNew = Sheets.Add
With wsNew
End Withwhere the cells properties are refering to the current sheet and the Range is refering to the new sheet. Doesn't make sense why a smaller argument would not throw the error, but perhaps I went too quickly and missed something. I'll have to check it again later this evening.

01-09-2013, 07:09 AM

Jan Karel Pieterse
01-09-2013, 07:12 AM
To correct your own code, replace




01-09-2013, 07:40 AM
picky picky:

01-09-2013, 10:05 AM
Alright. Thanks guys.