+ Reply to Thread
Results 1 to 2 of 2

Macro to Delete blank rows or column

Hybrid View

  1. #1
    Registered User
    Join Date
    04-27-2014
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    57

    Macro to Delete blank rows or column

    Hi,
    Can any one please suggest suggest macro to delete blank rows or column in the sheet.


    Thanks,
    Sriku

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Macro to Delete blank rows or column

    Sub DeleteBlankRows()
    Dim lLastRow As Long, lCount As Long
    
    lLastRow = ActiveSheet.UsedRange.Rows(UBound(ActiveSheet.UsedRange.Value)).Row
    Application.ScreenUpdating = False
    For lCount = lLastRow To 1 Step -1
    If Application.WorksheetFunction.CountA(Rows(lCount)) = 0 Then Rows(lCount).Delete
    Next
    Application.ScreenUpdating = True
    End Sub
    Sub DeleteBlankColumns()
    Dim lLastColumn As Long, lCount As Long
    
    lLastColumn = ActiveSheet.UsedRange.Columns(UBound(ActiveSheet.UsedRange.Value, 2)).Column
    Application.ScreenUpdating = False
    For lCount = lLastColumn To 1 Step -1
    If Application.WorksheetFunction.CountA(Columns(lCount)) = 0 Then Columns(lCount).Delete
    Next
    Application.ScreenUpdating = True
    End Sub
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

+ 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. Macro to delete blank rows if column I is blank for the row
    By tiger10012 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-10-2013, 03:01 PM
  2. [SOLVED] VBA Find last row and column that contain data and delete all blank rows and blank columns
    By bcn1988 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-03-2012, 01:07 PM
  3. Delete Rows if cell value in a column are blank
    By excelrequest in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-11-2010, 01:30 PM
  4. Delete ALL rows that have cell in Column (J) that looks blank
    By Sanne in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-11-2010, 11:10 PM
  5. [SOLVED] Delete entire rows where there is a blank in column A
    By Chris Hankin in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-11-2006, 05:00 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