ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Moving a worksheet to a new workbook when you do not know the name of worksheet (https://www.excelbanter.com/excel-programming/388023-moving-worksheet-new-workbook-when-you-do-not-know-name-worksheet.html)

Fireworks99

Moving a worksheet to a new workbook when you do not know the name of worksheet
 
I am trying to move 2 worksheets from 1 workbook to another where I know the
name of 1 worksheet but only have a variable with the name of the 2nd
worksheet. When I try the following.....

Sheets(Array(ThisSheetName, "Attribute Definitons")).Move

where "ThisSheetName" is the variable, i get a subscript out of range error
(9). Anyone have any thoughts on how to get around this? Thanks in advance.


Dave Peterson

Moving a worksheet to a new workbook when you do not know the nameof worksheet
 
I'd guess that you don't have a sheet by that name in the active workbook.

So maybe it's the variables fault (some sort of typo) or maybe you changed
workbooks???



Fireworks99 wrote:

I am trying to move 2 worksheets from 1 workbook to another where I know the
name of 1 worksheet but only have a variable with the name of the 2nd
worksheet. When I try the following.....

Sheets(Array(ThisSheetName, "Attribute Definitons")).Move

where "ThisSheetName" is the variable, i get a subscript out of range error
(9). Anyone have any thoughts on how to get around this? Thanks in advance.


--

Dave Peterson

urkec

Moving a worksheet to a new workbook when you do not know the name
 
Sheets(Array(ThisSheetName, "Attribute Definitons")).Move

Maybe you misspelled "Attribute Definitons" (Definitions ?)


--
urkec




All times are GMT +1. The time now is 03:24 PM.

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