PDA

View Full Version : Problem with Range and Worksheets



Marco83
07-08-2008, 10:45 AM
Hi everyone,

I am experiencing an odd problem; I have a piece of code in which I execute the following instruction:

Worksheets("LC1").Range("N3:P3") = Product.ComponentMolarFractionValue

and the result is as expected.

If now I change the way in which I define the range to the following:

Worksheets("LC1").Range(Cells(3, 14), Cells(3, 16)) = Product.ComponentMolarFractionValue

I get an error message:

Run-time error '1004':

Application-defined or Object-defined error

If instead of sending the data to the worksheet named LC1 I send them to InputOutput (which is the first worksheet in my workbook) everything is fine...

Clues?

Norie
07-08-2008, 11:06 AM
You need a worksheet reference for Cells.

With Worksheets("LC1")
.Range(.Cells(3, 14), .Cells(3, 16)) = Product.ComponentMolarFractionValue
End With