ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Placing values in a range on a non-active sheet (https://www.excelbanter.com/excel-programming/329021-placing-values-range-non-active-sheet.html)

Daniel Bonallack

Placing values in a range on a non-active sheet
 
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

Jim Thomlinson[_3_]

Placing values in a range on a non-active sheet
 
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

"Daniel Bonallack" wrote:

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


Vasant Nanavati

Placing values in a range on a non-active sheet
 
That's because you haven't qualified Cells.

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

should work.

--

Vasant


"Daniel Bonallack" wrote in
message ...
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




Daniel Bonallack

Placing values in a range on a non-active sheet
 
Thanks very much (and to Vasant).



"Jim Thomlinson" wrote:

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

"Daniel Bonallack" wrote:

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



All times are GMT +1. The time now is 11:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com