简体   繁体   中英

How to refer to an open workbook in VBA?

Dim test As Range

Set test = Workbooks("MonthlyReport.xlsb").Worksheets("VC Report").Range("C1")

VBA shows Error 9: Subscript out of range. Why is this? What is wrong with it? The workbook MonthlyReport.xlsb is open.

Your code works fine for me (Excel 2007 / Win 7). Check the spelling of the workbook and worksheet. (especially matching spaces)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM