+ Reply to Thread
Results 1 to 9 of 9

How do I delete all but columns A-E across multiple sheets in an xls file?

  1. #1
    Registered User
    Join Date
    10-12-2016
    Location
    London, England
    MS-Off Ver
    MIcrosoft Excel for Mac Version 16.33
    Posts
    17

    How do I delete all but columns A-E across multiple sheets in an xls file?

    Hello All

    I have an xls file containing around 400 sheets, which I will be splitting into individual files.

    However, before I do this, I would like to delete everything except columns A-E in every sheet to clean them up a bit.

    I have found various ways of deleting the same thing from multiple sheets in a workbook, but is there a way of simply keeping only columns A-E in every sheet, and clearing everything else?

    Your help will be greatly appreciated!

    (I am using Excel for Mac)

  2. #2
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,442

    Re: How do I delete all but columns A-E across multiple sheets in an xls file?

    Please Login or Register  to view this content.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: How do I delete all but columns A-E across multiple sheets in an xls file?

    click on the 1st sheet you want to include
    scroll to the last sheet you want to include
    hold SHIFT and click on the last sheet name

    You have now GROUPED all the sheets together. Whatever you do on 1, gets "punched" through to all the sheets.
    So highlight the columns you (dont) want, then delete them. If you did the grouping right, those columns should now contain nothing.

    A word of caution - make sure you UNGROUP the sheets when you are done, either by clicking on a sheet outside the group, or rig-click on a sheet name and select UNGROUP.
    If you dont do this, ANYTHING you do on ANY sheet in the group will be dome on all sheets. I have created hours of extra work for myself when I forget this step
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    10-12-2016
    Location
    London, England
    MS-Off Ver
    MIcrosoft Excel for Mac Version 16.33
    Posts
    17

    Re: How do I delete all but columns A-E across multiple sheets in an xls file?

    Quote Originally Posted by daboho View Post
    Please Login or Register  to view this content.
    Thanks!! At first I thought this wasn't working but I ran it about 7 times and it got rid of one column each time.

    Unfortunately there are "floating" graphs which remain, and was wondering if there is a way of deleting these all in one go, rather than going through all 400 sheets individually. I'll create a small sample document to show the situation and post it shortly.

  5. #5
    Registered User
    Join Date
    10-12-2016
    Location
    London, England
    MS-Off Ver
    MIcrosoft Excel for Mac Version 16.33
    Posts
    17

    Re: How do I delete all but columns A-E across multiple sheets in an xls file?

    Quote Originally Posted by FDibbins View Post
    click on the 1st sheet you want to include
    scroll to the last sheet you want to include
    hold SHIFT and click on the last sheet name

    You have now GROUPED all the sheets together. Whatever you do on 1, gets "punched" through to all the sheets.
    So highlight the columns you (dont) want, then delete them. If you did the grouping right, those columns should now contain nothing.

    A word of caution - make sure you UNGROUP the sheets when you are done, either by clicking on a sheet outside the group, or rig-click on a sheet name and select UNGROUP.
    If you dont do this, ANYTHING you do on ANY sheet in the group will be dome on all sheets. I have created hours of extra work for myself when I forget this step
    Thanks! As they all had different extra bits I was hoping that I could just select the columns I wished to keep and delete everything else, but the code above seems to leave graphs floating around the place. I'll have a go at using this method to see if it gets rid of the extra bits left behind.

  6. #6
    Registered User
    Join Date
    10-12-2016
    Location
    London, England
    MS-Off Ver
    MIcrosoft Excel for Mac Version 16.33
    Posts
    17

    Re: How do I delete all but columns A-E across multiple sheets in an xls file?

    Right I think I have attached a sample file to this post now, so when I run the VBA on this sample document it removes everything beyond column E one column per time the code is run.

    When I do this with the full 400 sheet file, those floating graphs you see there are left behind on most of the sheets, any quick way to solve this?
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    10-12-2016
    Location
    London, England
    MS-Off Ver
    MIcrosoft Excel for Mac Version 16.33
    Posts
    17

    Re: How do I delete all but columns A-E across multiple sheets in an xls file?

    Quote Originally Posted by zvba010 View Post
    Thanks! As they all had different extra bits I was hoping that I could just select the columns I wished to keep and delete everything else, but the code above seems to leave graphs floating around the place. I'll have a go at using this method to see if it gets rid of the extra bits left behind.
    I've now tried both methods and unfortunately all of the graphs are left behind such as in this screenshot:

    https://imgur.com/Sxnovvv

    Any ideas how to delete these from all sheets?

    Thanks
    Last edited by zvba010; 12-28-2019 at 02:56 PM.

  8. #8
    Registered User
    Join Date
    10-12-2016
    Location
    London, England
    MS-Off Ver
    MIcrosoft Excel for Mac Version 16.33
    Posts
    17

    Re: How do I delete all but columns A-E across multiple sheets in an xls file?

    I've realised the chart is using data from columns A and B which is why they are not being deleted, how do I get rid of charts from all sheets?

  9. #9
    Registered User
    Join Date
    10-12-2016
    Location
    London, England
    MS-Off Ver
    MIcrosoft Excel for Mac Version 16.33
    Posts
    17

    Re: How do I delete all but columns A-E across multiple sheets in an xls file?

    Quote Originally Posted by zvba010 View Post
    Thanks! As they all had different extra bits I was hoping that I could just select the columns I wished to keep and delete everything else, but the code above seems to leave graphs floating around the place. I'll have a go at using this method to see if it gets rid of the extra bits left behind.
    I found this code which deletes all charts:

    Please Login or Register  to view this content.
    It prompts each time with message box but I just held down the return key and it didn't take too long to get through all 400.

    Thanks for all your help, I'll now mark this as solved
    Last edited by FDibbins; 12-29-2019 at 01:33 AM.

+ 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. Multiple CSV in Folder, Delete Columns based on Header Name for Every File
    By ramkrau in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-10-2019, 01:16 PM
  2. unable to delete entire row of empty cells in columns across multiple sheets.
    By CCLaMor in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-09-2014, 02:03 PM
  3. [SOLVED] Delete Columns in Multiple Sheets with repeat macro
    By candie025 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-17-2014, 03:01 AM
  4. Replies: 1
    Last Post: 10-24-2013, 01:05 PM
  5. Macro to delete sheets and saves remaining file does not properly delete module
    By pherrero in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-21-2005, 08:12 PM
  6. Replies: 0
    Last Post: 06-21-2005, 01:05 PM
  7. Re: Macro to delete sheets and saves remaining file does not properly delete module
    By pherrero in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-21-2005, 01:05 PM

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