+ Reply to Thread
Results 1 to 2 of 2

Problem with adding new sheet

Hybrid View

  1. #1
    Forum Contributor Mayda89's Avatar
    Join Date
    09-13-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    192

    Problem with adding new sheet

    Hi,

    A part of the macro I wrote adds a new sheet to the active workbook. Until now, the code was working fine, but today I encountered the error message "That Command cannot be used on multiple selections", while trying to run the simple code:
    Sheets.add
    Please note that the workbook is not protected, and multiple sheets are not selected. I have also tried this:
    ActiveWorkbook.Sheets.add
    and this:
    MyWorkbook.activate
    ActiveWorkbook.Sheets.add
    but none works.

    I have realized that this error happens only when the other part of the macro runs the following code:
    ActiveWorkbook.SaveCopyAs
    So when the SaveCopyAs code has not been run, I don't encounter any problem with adding sheets.

    I cannot understand why this error happens, because before even when the code SaveCopyAs was ran I did not have any problem with adding sheets, and since then I have not changed anything about this part of the code where it adds new sheets.

    Somewhere on the web somebody suggests using the following code:
    Worksheets.Item(1).Select
    before the add code, but it doesn't solve my problem. (I assume because my problem is not that multiple sheets are selected, because in the title bar I see no [Grouped] sign.)

    Note that I am using Excel 2010.

    P.S: After running the SaveCopyAs code mentioned above, I also cannot add sheets manually via Excel.

  2. #2
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    Re: Problem with adding new sheet

    I think somewhere in the code you are selecting non ointiguous cells for copying review the macros code by code
    I am not an expert. better solutions may be available
    [email protected]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1