ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sheets("sheet1").Range command between workbooks (https://www.excelbanter.com/excel-programming/341217-sheets-sheet1-range-command-between-workbooks.html)

Luc[_3_]

Sheets("sheet1").Range command between workbooks
 
I would like to use the e.g.
Sheets("sheet1").Range("ac2") = Sheets("sheet2").Range("b2")
command (which works within a wookbook) but between 2 workbooks. How can I
impose a value of workbook1 to workbook2 in the assumption that wookbook2 is
open?

K Dales[_2_]

Sheets("sheet1").Range command between workbooks
 
General form is:
Workbooks("Workbook1").Worksheets("Sheet1").Range( "ac2")=Workbooks("Workbook2").Worksheets("Sheet2") .Range("b2")
Substitute in your workbook names (exactly as they show in the Excel title
bar when the workbook is open, or in the Project Explorer list in the VBA
editor).
--
- K Dales


"Luc" wrote:

I would like to use the e.g.
Sheets("sheet1").Range("ac2") = Sheets("sheet2").Range("b2")
command (which works within a wookbook) but between 2 workbooks. How can I
impose a value of workbook1 to workbook2 in the assumption that wookbook2 is
open?


Luc[_3_]

Sheets("sheet1").Range command between workbooks
 
thanks works

"K Dales" wrote:

General form is:
Workbooks("Workbook1").Worksheets("Sheet1").Range( "ac2")=Workbooks("Workbook2").Worksheets("Sheet2") .Range("b2")
Substitute in your workbook names (exactly as they show in the Excel title
bar when the workbook is open, or in the Project Explorer list in the VBA
editor).
--
- K Dales


"Luc" wrote:

I would like to use the e.g.
Sheets("sheet1").Range("ac2") = Sheets("sheet2").Range("b2")
command (which works within a wookbook) but between 2 workbooks. How can I
impose a value of workbook1 to workbook2 in the assumption that wookbook2 is
open?


Chip Pearson

Sheets("sheet1").Range command between workbooks
 
Try something like

Workbooks("Book2.xls").Sheets("sheet1").Range("ac2 ") = _
Workbooks("Book1.xls").Sheets("sheet2").Range("b2" )



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Luc" wrote in message
...
I would like to use the e.g.
Sheets("sheet1").Range("ac2") = Sheets("sheet2").Range("b2")
command (which works within a wookbook) but between 2
workbooks. How can I
impose a value of workbook1 to workbook2 in the assumption that
wookbook2 is
open?





All times are GMT +1. The time now is 06:14 AM.

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