Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Macros - Sheet Names

Status
Not open for further replies.

mathias1979

Technical User
Sep 28, 2005
27
US
Using Macros in Excel...is there a way to run a Macro in different workbook even if the sheet are not the same? In other words...if I record a macro that copies data from a sheet titled "Sheet 1" to a sheet titled "Sheet 2"...is it possible to run this in another workbook where the sheets are named "Page 1" and "Page 2" by somehow telling the Macro to just copy data from the first page in the workbook to the second page in the workbook...regardless of their names?
 
mathias1979,

If you are talking about workbooks which contain only two sheets or you are only interested in the first and second sheets then you could reconfigure your macro to reference Sheets(1) and Sheets(2) rather than Sheets("Sheet 1") and Sheets("Sheet 2") etc.

ie. you should reference the Sheets by their index numbers rather than by Name.

HTH Hugh,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top