+ Reply to Thread
Results 1 to 3 of 3

Error “A table can’t overlap another table” when creating a new sheet

  1. #1
    Registered User
    Join Date
    05-13-2019
    Location
    Eskilstuna
    MS-Off Ver
    Office 2016
    Posts
    45

    Error “A table can’t overlap another table” when creating a new sheet

    I have a really strange problem that’s been bothering me for some time now. I have this planning workbook, it’s for a small stab – they want to plan their time schedule for a year ahead for every co-worker. The workbook is built on a couple of sheets, Template, calendar and so on - most of them are hidden. At the start-sheet there are this button “Ny medarbetare” who is the button to create a new sheet for every co-worker. First you come to a form where it’s necessary to fill every textbox and then you push on the button “Skapa” to create the new sheet. And here is where the problem starts and ONLY if there are no other sheets for co-workers. If there are other co-worker sheets it’s seems to be working fine (seems maybe is the keyword though it’s has’nt been testing yet). But if there is no other co-worker sheets yet, I get this error “A table cant overlap another table” and then its creating a Template(2) out of an existing sheet (and just rename it) and a co-workers sheet that is only half created and without the template.

    I’m not that experienced with VBA so this is really bothering me. Adding some pictures of the described errors and the code that is creating the new sheet.

    Please Login or Register  to view this content.
    Hope anyone has any ideas.
    Attached Images Attached Images

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Error “A table can’t overlap another table” when creating a new sheet

    Can't say I know what the issue is, but a few things:

    1. Why are you using a Private Function to do work, instead of a Sub (Public or Private)? While they both can do work, functions are usually used to perform calculations and return a value to another function or sub (or custom worksheet function).

    2. You Dim a 'newSheetName' but never use it in the code.

    3. Generally you can use ThisWorkbook.Worksheets.Count. Not much need to create a variable to count/store the number of worksheets. Also, use Long instead of Integer. Excel just converts Int's to Long anyway. See here.

  3. #3
    Registered User
    Join Date
    05-13-2019
    Location
    Eskilstuna
    MS-Off Ver
    Office 2016
    Posts
    45

    Re: Error “A table can’t overlap another table” when creating a new sheet

    Thanks for the answer!

    I'm not the one who wrote this code, but I'm guessing the function is there because the return value (the sheet) needs some more work to be done after the sheet is created. It's in use in the method that is calling the function.

    The other suggestions didn't change the functions behavior, sad to say.. but all suggestions is very appreciated so thank you very much.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 12-08-2017, 02:41 PM
  2. Creating a table based on a table in another sheet
    By kwjoh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-06-2015, 04:09 PM
  3. Run Time Error "1004": A table cannot overlap another table
    By Shermaine2010 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-05-2015, 06:30 AM
  4. Run-time error 1004 Table Cannot Overlap A Range...
    By dearnemo385 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-14-2012, 08:19 AM
  5. Run-time error 1004 Table Cannot Overlap A Range...
    By passmaster16 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-11-2012, 10:21 AM
  6. Replies: 0
    Last Post: 05-09-2012, 03:59 PM
  7. Creating a filtered table from a source table in another sheet
    By penfold in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-12-2008, 07:44 AM

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