Closed Thread
Results 1 to 2 of 2

Delete blank rows

  1. #1
    Registered User
    Join Date
    01-13-2022
    Location
    Motta di Livenza, Italy
    MS-Off Ver
    Excel 2016
    Posts
    25

    Delete blank rows

    Hello there,

    I have a problem with a loop which is supposed to delete rows depending on whether the last column contains blank cells or not. If a cell is blank in the last column, then its respective row has to be deleted.

    I'm using this part of the Sub to identify the blank cells in the last column, based on the criteria that I need, and I have no problems with it, it's working fine:

    Worksheets("Cash MIS Data").Activate

    Dim x As Long
    Dim i_column As Long
    Dim n_column As Long

    n_column = Sheets("Cash MIS Data").Cells(1, Columns.Count).End(xlToLeft).Column

    With Cells(1).CurrentRegion.Resize(, n_column + 1)
    With .Columns(n_column + 1)
    .Formula = "=IF(AND(COUNTIF(A:A,LEFT(A1,10)&""*"")>1,RIGHT(A1,3)=""671""),"""",A1)"
    .Value = .Value
    End With

    End With


    However, the second part of the code (hereunder) is not working properly, in the sense that it works perfectly for some sheets, but only partially for others: I don't get any error, but I can see from the final result that not all the rows with a blank cell in the last column have been deleted.

    Dim i_row As Long
    Dim n_row As Long

    n_row = Sheets("Cash MIS Data").Cells(Rows.Count, n_column + 1).End(xlUp).Row

    With Sheets("Cash MIS Data")
    For i_row = 1 To n_row
    If .Cells(i_row, n_column + 1).Value = "" Then
    .Cells(i_row, n_column + 1).EntireRow.Delete
    End If
    Next i_row

    End With

    Columns(n_column + 1).Clear


    Is there anything wrong about it?

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,870

    Re: Delete blank rows

    Administrative Note:

    Welcome to the forum.

    Unfortunately, this is a duplicate thread, and you are allowed only ONE thread per issue here.

    Please see Forum Rule #5 about thread duplication.

    I am closing this thread, but you may continue here in the original thread
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. move data upwards to a blank row and delete all blank rows below
    By RIZVI in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-29-2019, 09:31 AM
  2. [SOLVED] Delete blank rows between blocks of data except two blank rows
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-26-2018, 11:18 AM
  3. [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
  4. [SOLVED] How to Delete Multiple Consecutive Blank Rows - Delete all Blank Rows
    By raw_geek in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-16-2012, 03:17 PM
  5. [SOLVED] Delete blank rows after filter - if no blank rows exit sub
    By cmb80 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-27-2012, 10:00 AM
  6. Replies: 1
    Last Post: 05-10-2012, 04:58 PM
  7. [SOLVED] To delete blank rows having blank cell in the needed raws
    By Alexander_Golinsky in forum Excel General
    Replies: 4
    Last Post: 05-04-2012, 03:11 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