+ Reply to Thread
Results 1 to 4 of 4

VBA Delete Hidden Rows & Columns

  1. #1
    Registered User
    Join Date
    08-23-2020
    Location
    Dubai, UAE
    MS-Off Ver
    365
    Posts
    10

    Exclamation VBA Delete Hidden Rows & Columns

    Hi There,

    I was wondering if anyone has a faster way of deleting hidden rows and columns in the file. I used this method and it is taking quite long to delete the hidden rows and layers. In terms of columns I have about 80, in terms of rows I have 121

    Dim LastRow As Integer
    Dim LastCol As Integer
    Set sht = ActiveSheet
    LastRow = ActiveSheet.UsedRange.Rows(sht.UsedRange.Rows.Count).row
    LastCol = ActiveSheet.UsedRange.Columns(sht.UsedRange.Columns.Count).Column

    For i = LastRow To 1 Step -1
    If Rows(i).Hidden = True Then Rows(i).EntireRow.Delete
    Next

    For i = LastCol To 1 Step -1
    If Columns(i).Hidden = True Then Columns(i).EntireColumn.Delete
    Next
    End Sub


    Thanks a bunch!

    Will
    Last edited by waelou; 07-01-2021 at 12:56 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    06-23-2021
    Location
    Romania
    MS-Off Ver
    2021, 365 v 2208
    Posts
    722

    Re: VBA Delete Hidden Rows & Columns

    Hi,
    You have 80 columns hidden or 80 in total?
    They are hidden because of a filter action or manually?

  3. #3
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,222

    Re: VBA Delete Hidden Rows & Columns

    waelou
    Please edit your first post and include the cited code in tags
    Please Login or Register  to view this content.
    Artik

  4. #4
    Registered User
    Join Date
    08-23-2020
    Location
    Dubai, UAE
    MS-Off Ver
    365
    Posts
    10

    Re: VBA Delete Hidden Rows & Columns

    Hello,

    Thanks!! it worked!!

    Best,

    Will

+ 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. [SOLVED] Delete Table Rows of filtered data - when some columns are hidden
    By BG1983 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-01-2017, 10:42 PM
  3. Replies: 1
    Last Post: 04-08-2014, 02:50 AM
  4. Replies: 4
    Last Post: 06-11-2010, 03:29 PM
  5. Delete hidden rows & columns
    By tommy_gtr in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-04-2007, 06:12 AM
  6. Delete Hidden Rows
    By Makeda in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 05-18-2005, 03:03 PM
  7. Keeping Hidden Rows/Columns Hidden?
    By DMac in forum Excel General
    Replies: 0
    Last Post: 01-17-2005, 08:13 PM

Tags for this Thread

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