Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 21
Default Using cell as worksheet reference (macro)

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).Act ivate

Any suggestions?

Ed
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default Using cell as worksheet reference (macro)

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!*


"Edwin" wrote:

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).Act ivate

Any suggestions?

Ed

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 21
Default Using cell as worksheet reference (macro)

Thanks Luke, works great!

Edwin


"Luke M" wrote:

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!*


"Edwin" wrote:

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).Act ivate

Any suggestions?

Ed

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you get a macro to reference the worksheet it is being run Michelle D[_2_] Excel Discussion (Misc queries) 2 August 11th 09 10:17 AM
Cell Reference Macro Scott Excel Discussion (Misc queries) 3 June 16th 09 04:13 PM
cell reference in macro AJB Excel Discussion (Misc queries) 2 August 7th 07 04:22 PM
Macro to Create New Worksheet and Reference Cell in Old Worksheet As Tab Name - "Object Required" Error [email protected] Excel Discussion (Misc queries) 4 September 25th 06 01:35 PM
Worksheet reference (i.e placing worksheet name in a cell) Roger Roger Excel Worksheet Functions 1 January 20th 05 03:40 PM


All times are GMT +1. The time now is 06:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"