+ Reply to Thread
Results 1 to 8 of 8

VBA to Split and/or Unsplit worksheet

  1. #1
    Registered User
    Join Date
    10-21-2023
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    22

    VBA to Split and/or Unsplit worksheet

    I'm looking for a VBA routine to Split and Unsplit worksheet. For some reason I have a routine that is splitting my screen and I can't figure out where it is doing this. When the screen is split, other procedures fail. If I manually "unsplit" the screen all work fine. I'd like to just add an Unsplit code to fix this.

    Thanks,
    Steve K.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA to Split and/or Unsplit worksheet

    Hi there,

    See if the following code does what you need:

    Please Login or Register  to view this content.

    Hope this helps.

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    10-21-2023
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    22

    Re: VBA to Split and/or Unsplit worksheet

    Thank you Greg - much appreciated. However, I'm still having a problem. I placed the code as the first thing in my Auto_Open routine. The worksheet is still split horizontally. If I manually separate the split then select View > Split (which is highlighted), the worksheet is now "unsplit" and the coding works great. I tried recording a macro but it records nothing.

    Steve
    Last edited by S.K.K.; 10-31-2023 at 04:46 PM.

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA to Split and/or Unsplit worksheet

    Hi again,

    Using the Workbook_Open (rather than the Auto_Open) routine seems to work for me:

    Please Login or Register  to view this content.
    Obviously the above code must be entered in the "ThisWorkbook" VBA CodeModule.


    Does this help?

    Regards,

    Greg M

  5. #5
    Registered User
    Join Date
    10-21-2023
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    22

    Re: VBA to Split and/or Unsplit worksheet

    Thanks again Greg, I truly appreciate your input and concern.

    I placed the code in ThisWorkbook but it did not close or hide or remove or unsplit or whatever. The worksheet is still split. I could manually unsplit. I first just added the code to ThisWorkbook but did not work. I next removed (changed the name of) Auto_Open so it did not run - only had ThisWorkbook was enabled but it still did not "unsplit" the worksheet.

  6. #6
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA to Split and/or Unsplit worksheet

    Hi again,

    Ok, what I did was to:

    1. save the workbook with the "Workbook_Open" routine included;

    2. perform a "four-way split" at a random location on the screen;

    3. save the workbook again;

    4. close the workbook;

    5. re-open the workbook - the split was no longer present.


    My system uses Excel 2016.

    Maybe you can identify something you did/didn't do at your end?

    Regards,

    Greg M

  7. #7
    Registered User
    Join Date
    10-21-2023
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    22

    Re: VBA to Split and/or Unsplit worksheet

    Greg,

    I think I found a work-around. I added a line to the beginning of your code "ActiveWindow.SplitRow = 4" and now all appears to be working fine. I placed the code in the Workbook_Open sub as I believe this kicks off before Auto_Open. I was never aware of Workbook_Open - I like it.

    Thanks again for your time - much appreciated,
    Steve

  8. #8
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA to Split and/or Unsplit worksheet

    Hi again Steve,

    Many thanks for your feedback - much appreciated!

    I think that "Auto_Open" was superseded by "Workbook_Open", but remains available in order to provide backwards-compatability.

    You're welcome - glad I was able to help.

    Regards,

    Greg M

+ 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. [SOLVED] VBA to split worksheet
    By GregThePeg in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-22-2014, 12:15 PM
  2. Split Worksheet
    By moldo89 in forum Excel General
    Replies: 4
    Last Post: 10-21-2013, 01:11 AM
  3. [SOLVED] Split worksheet
    By Luphai in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 01-22-2013, 06:13 AM
  4. [SOLVED] Split one worksheet into multiple worksheet by column
    By vdivgi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-19-2012, 11:05 AM
  5. [SOLVED] How to split a worksheet
    By JP3 in forum Excel General
    Replies: 0
    Last Post: 02-06-2006, 05:40 PM
  6. [SOLVED] RE: How to split a worksheet
    By Ron Coderre in forum Excel General
    Replies: 0
    Last Post: 02-06-2006, 05:35 PM
  7. Split worksheet?
    By Richard in forum Excel General
    Replies: 4
    Last Post: 05-19-2005, 10:06 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