![]() |
Array error
Hello All,
I have encountered the following error message: Run-time error '9' Subscript out of range sName1 = sh.Name & " Hi" sName2 = sh.Name & " Hello" Sheets(Array(sName1, sName2)).Copy The copy statement works if I replace the variables with actual sheet name. May anyone give some hints to me? Thanks in advance! Regards, PW |
Array error
pwz wrote:
Hello All, I have encountered the following error message: Run-time error '9' Subscript out of range sName1 = sh.Name & " Hi" sName2 = sh.Name & " Hello" Sheets(Array(sName1, sName2)).Copy The copy statement works if I replace the variables with actual sheet name. May anyone give some hints to me? Thanks in advance! Regards, PW What is sh? Alan Beban |
Array error
Dear Alan,
Sorry that 'sh' is also a variable of worksheet. I finally figure out the solution. I need to use another variable to capture the name of the worksheet and use this new variable to concantenate with other text to form new worksheet names. Then, the array formula in copy statement works. The problem now is that I don't know the reason behind. Anyway, thanks to you! PW "Alan Beban" wrote in message ... pwz wrote: Hello All, I have encountered the following error message: Run-time error '9' Subscript out of range sName1 = sh.Name & " Hi" sName2 = sh.Name & " Hello" Sheets(Array(sName1, sName2)).Copy The copy statement works if I replace the variables with actual sheet name. May anyone give some hints to me? Thanks in advance! Regards, PW What is sh? Alan Beban |
All times are GMT +1. The time now is 01:25 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com