+ Reply to Thread
Results 1 to 11 of 11

VBA to delete hidden (unfiltered) rows

  1. #1
    Forum Contributor
    Join Date
    07-21-2018
    Location
    London, England
    MS-Off Ver
    Excel for Mac Version 16.15
    Posts
    117

    VBA to delete hidden (unfiltered) rows

    Hello,

    I am having some problems with my code.

    The code I have written (below);

    1. Allows the user to choose a CSV file from the file browser and import the data to a new workbook
    2. Filters the data using an advanced filter
    3. Deletes hidden (filtered out) data

    Please Login or Register  to view this content.
    Everything runs fine except from step 3 (deleting the hidden rows). When I run the code below on it's own it works as expected, but for some reason it's not completing when added to the full code.

    Please Login or Register  to view this content.
    Can anyone help?
    Attached Files Attached Files

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: VBA to delete hidden (unfiltered) rows

    Your code seems to work for me.

    If you did want to make it faster, you could just copy the filtered data to P1 and delete columns A:O

    For example

    Please Login or Register  to view this content.
    Edit the code to use your variables.

  3. #3
    Forum Contributor
    Join Date
    07-21-2018
    Location
    London, England
    MS-Off Ver
    Excel for Mac Version 16.15
    Posts
    117

    Re: VBA to delete hidden (unfiltered) rows

    Hm really? When I run the code this is what I get;

    Screenshot 2019-02-26 at 10.56.10.png

    Which shows me that the delete hidden rows part isn't working.

    When I isolate that part of the code and run it it works and I'm left with data in rows 1 to 56 only.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: VBA to delete hidden (unfiltered) rows

    I don't get the same results when I use your code.
    Here's a pic that shows what got filtered and after the hidden rows are deleted.
    Could it be because you are on MAc?
    -


    DleteFilteredrows.jpg

  5. #5
    Forum Contributor
    Join Date
    07-21-2018
    Location
    London, England
    MS-Off Ver
    Excel for Mac Version 16.15
    Posts
    117

    Re: VBA to delete hidden (unfiltered) rows

    That is strange. I'm on a PC now and getting the same results as on my MAC. Using the code and CSV file from my first post...

  6. #6
    Forum Contributor
    Join Date
    07-21-2018
    Location
    London, England
    MS-Off Ver
    Excel for Mac Version 16.15
    Posts
    117

    Re: VBA to delete hidden (unfiltered) rows

    Can anyone else help with this? I don't understand why this part of the code works for me when used in a separate sub but not when added to the rest of the code;

    Please Login or Register  to view this content.
    It's possibly just a syntax error?

  7. #7
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: VBA to delete hidden (unfiltered) rows

    If we are working on the same workbook, we should be getting the same results.

  8. #8
    Forum Contributor
    Join Date
    07-21-2018
    Location
    London, England
    MS-Off Ver
    Excel for Mac Version 16.15
    Posts
    117

    Re: VBA to delete hidden (unfiltered) rows

    Hey! I am opening a blank workbook and copying the code from my first post into the This Sheet module and running it - selecting the CSV file I attached to my first post. I am getting the results that I shared above. Are you doing something different?

    Thanks!

  9. #9
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: VBA to delete hidden (unfiltered) rows

    Here is a small clip on exactly how I'm doing it.
    It looks like you are doing the same thing, but getting different results?

    https://drive.google.com/file/d/1BJM...w?usp=drivesdk

  10. #10
    Forum Contributor
    Join Date
    07-21-2018
    Location
    London, England
    MS-Off Ver
    Excel for Mac Version 16.15
    Posts
    117

    Re: VBA to delete hidden (unfiltered) rows

    That's exactly what I'm doing too (minus the indent part). I noticed your CSV file starts with 'copy' - are you using the exact file I attached from the first post?

  11. #11
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: VBA to delete hidden (unfiltered) rows

    It just opened in the temp folder, so when I saved it to a specific location, it saved as a copy, I just opened the one in the temp folder, and got the same results.

+ 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: 10
    Last Post: 06-07-2018, 04:16 PM
  2. Replies: 1
    Last Post: 04-08-2014, 02:50 AM
  3. [SOLVED] need vba code to unfiltered all filtered col and unhide all hidden col through closed wb
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-24-2014, 12:44 PM
  4. Replies: 4
    Last Post: 06-11-2010, 03:29 PM
  5. Remove unfiltered rows of a customview
    By Robinson78 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-01-2008, 03:51 PM
  6. Delete hidden rows & columns
    By tommy_gtr in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-04-2007, 06:12 AM
  7. Delete Hidden Rows
    By Makeda in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 05-18-2005, 03:03 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