Placing values in a range on a non-active sheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Do I have to select a sheet before placing values in a range?

This works:
Sheets("Product").select
Range(Cells(1, 2), Cells(1, 11)).Value = 1000

This doesn't:
Sheets("Product").Range(Cells(1, 2), Cells(1, 11)).Value = 1000

Thanks in advance.
Daniel
 
You can do it but you have to be very explicit with all of your
references.Something like this will work

Sheets("Product").Range(Sheets("Product").Cells(1, 2),
Sheets("Product").Cells(1, 11)).Value = 1000

or you could use a with statement

with Sheets("Product")
.Range(.Cells(1, 2), .Cells(1, 11)).Value = 1000
end with

HTH
 
That's because you haven't qualified Cells.

With Sheets("Product")
.Range(.Cells(1, 2), .Cells(1, 11)).Value = 1000
End With

should work.
 
Thanks very much (and to Vasant).



Jim Thomlinson said:
You can do it but you have to be very explicit with all of your
references.Something like this will work

Sheets("Product").Range(Sheets("Product").Cells(1, 2),
Sheets("Product").Cells(1, 11)).Value = 1000

or you could use a with statement

with Sheets("Product")
.Range(.Cells(1, 2), .Cells(1, 11)).Value = 1000
end with

HTH
 

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

Back
Top