dcsimg
Results 1 to 6 of 6

Thread: [PowerPoint] Delete multiple rows in a table at once using VBA

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2012
    Posts
    55

    [PowerPoint] Delete multiple rows in a table at once using VBA

    Hi,

    Anyone can help me how to delete multiple rows in a PowerPoint table at once using VBA?

    Background info:

    I've created a VBA macro that deletes rows from a table on a PowerPoint slide. It's part of a larger macro that "splits" a table that doesn't fit on a single slide over multiple slides. (The table is generated outside PowerPoint.)

    The base process is that it copies the slide with the too long table the required number of times, and then removes the rows that don't apply to that slide. E.g. the table has 75 rows, and I want 25 per slide. The original slide is copied 2x, so that there are 3 slides with the full table. On the first we delete rows 26-75, on the second we delete rows 1-25 and 51-75, and on the third slide rows 1-50.

    This works fine for small tables, but a table with 265 rows that has to be split over 10 slides, already takes us 5 minutes to process. On an Intel i9 with 64GB RAM... On an Intel i5 it takes up more than 20 minutes!

    The slow part is related to the fact that each row is deleted individually, which apparently creates significant overhead. Because if I manually select 200+ rows, right mouse click, and say delete rows, it only takes a second or two.

    Unfortunately I have not been able to find a way to delete multiple rows at once. The Delete-method seems to allow one row-number only, and not a range like e.g. Excel. I thought about selecting multiple rows or cells, but the Selected property is read-only. I thought about setting the row-height to 0, but that doesn't work if there is data in the cells.

    Hopefully somebody has an idea!

    Thanks in advance,
    Erwin
    Last edited by Erwin69; May 17th, 2020 at 04:24 AM. Reason: Adding the requested [PowerPoint] tag in the title

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,852

    Re: [PowerPoint] Delete multiple rows in a table at once using VBA

    i will try to have a look tomorrow
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,852

    Re: [PowerPoint] Delete multiple rows in a table at once using VBA

    it may be faster to break up the table data into units of 25 rows, then populate into tables of 25 rows on the number of slides required

    you can add however many slides and add a table of 25 rows to the new slide then populate the table from the data
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2012
    Posts
    55

    Re: [PowerPoint] Delete multiple rows in a table at once using VBA

    We (unfortunately) have to start with the full table, as it (and the rest of the presentation) is created automatically by another software application. The idea to use a VBA macro is to provide flexibility. E.g. it is unknown up front if there are titles, subtitles, footers, logo's, etc. on the slide. It is also unknown which formatting (among others font size) has been chosen, which impacts the number of rows that fit on the slide.

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2012
    Posts
    55

    Re: [PowerPoint] [NOT resolved] Delete multiple rows in a table at once using VBA

    So far no luck with finding a solution to speed up the deleting of rows in a table. Strange, since this is lightning fast when done manually...

    The conclusion so far is that creating multiple slides with the right size table per slide, and then populating all these tables from scratch with the data in the original table using VBA code is 20+ times faster than deleting the rows...

    It's not the solution I was looking for, so if anyone has a good idea how to delete multiple rows in a fast way, I'm still interested to hear.

    But for those experiencing the same problem, don't hold your breath, create new tables and copy the data from the original table.

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,852

    Re: [PowerPoint] Delete multiple rows in a table at once using VBA

    IF you can import the table into excel first it would be easy to delete the rows then copy those tables into the slides
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width