ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Populating a Range by Code (https://www.excelbanter.com/excel-programming/303027-populating-range-code.html)

Nigel Bennett

Populating a Range by Code
 
When a user selects an item from a list box I would like
it to go and select a range of from a sheet and
insert it in to another sheet, I tried doing this

Sheets("Book vs Plan").Range("d50:o50") = Sheets
("plan").Range("d4:o4")

but that failed, no error messages but no data either.

Can someone help me with the correct syntax

Thanks


Ron de Bruin

Populating a Range by Code
 
Hi Nigel

Only add .value and it is working

Sub test()
Sheets("Book vs Plan").Range("d50:o50").Value = _
Sheets("plan").Range("d4:o4").Value
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Nigel Bennett" wrote in message ...
When a user selects an item from a list box I would like
it to go and select a range of from a sheet and
insert it in to another sheet, I tried doing this

Sheets("Book vs Plan").Range("d50:o50") = Sheets
("plan").Range("d4:o4")

but that failed, no error messages but no data either.

Can someone help me with the correct syntax

Thanks




Jim Rech

Populating a Range by Code
 
Further to Ron...

The default property of the range object is .Value and so Excel almost
always uses it when it's omitted as you have done. But not always. Fwiw, I
never assume the default will work; I always specify what I want (.Value in
this case.)

--
Jim Rech
Excel MVP

"Nigel Bennett" wrote in message
...
| When a user selects an item from a list box I would like
| it to go and select a range of from a sheet and
| insert it in to another sheet, I tried doing this
|
| Sheets("Book vs Plan").Range("d50:o50") = Sheets
| ("plan").Range("d4:o4")
|
| but that failed, no error messages but no data either.
|
| Can someone help me with the correct syntax
|
| Thanks
|




All times are GMT +1. The time now is 12:47 AM.

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