Using cell as worksheet reference (macro)

E

Edwin

Hi,

I would like to use the content of a cell as a worksheet reference. When the
macro is run, the name in the cell should open the worksheet of the same name
in another workbook.

So, in workbook A, I have in cell A1 "ed" (without the quotes). I want to
activate worksheet "ed" in workbook B. Workbook B is already open.

I have the following code in Workbook A, but is not working:

Windows("B.xls").Worksheets(Range("A1").Value).Activate

Any suggestions?

Ed
 
E

Edwin

Thanks Luke, works great!

Edwin


Luke M said:
Break it out as multiple lines:

xSheet = Range("A1")
Windows("Book1").Activate
Worksheets(xSheet).Select

Alternative, if you want to save a line:
Windows("Book1").Activate
Worksheets(ThisWorkbook.Sheets("My Sheet").Range("A1").Value).Select
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top