ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" (https://www.excelbanter.com/excel-programming/341374-use-variable-workbooks-book1-worksheets-sheet1-range-a1.html)

Luc[_3_]

use variable in Workbooks("book1").Worksheets("sheet1").Range("a1"
 
Is there a way that you can put a variable instead of "book1" in the
Workbooks("book1").Worksheets("sheet1").Range("a1" ) statement?

Ron de Bruin

use variable in Workbooks("book1").Worksheets("sheet1").Range("a1"
 
Hi Luc

Try this

Dim wb As Workbook
Set wb = Workbooks("Book1.xls")
wb.Sheets("Sheet1").Range("a1").Select

change Set wb = Workbooks("Book1.xls")



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


"Luc" wrote in message ...
Is there a way that you can put a variable instead of "book1" in the
Workbooks("book1").Worksheets("sheet1").Range("a1" ) statement?




Jim Thomlinson[_4_]

use variable in Workbooks("book1").Worksheets("sheet1").Range("a1"
 
dim strBook as string
strBook = "book1"
Workbooks(strBook ).Worksheets("sheet1").Range("a1")

--
HTH...

Jim Thomlinson


"Luc" wrote:

Is there a way that you can put a variable instead of "book1" in the
Workbooks("book1").Worksheets("sheet1").Range("a1" ) statement?



All times are GMT +1. The time now is 08:28 PM.

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