+ Reply to Thread
Results 1 to 13 of 13

Clearing empty rows

  1. #1
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,723

    Clearing empty rows

    Hello,

    I have this clearing empty row code but it does not work if there is not entry in A:A.

    Can the A1:A be taken out? I tried it to removed it and left it as ?? but it did not work either.
    I just want the code to work when there is no entry at all in the empty row.

    In the sample attachment, when I clicked the button then the A3 row not supposed to delete because there is an entry on the other column although the a column is blank. The only thing that it should be deleted it the 8th row because there nothing there.

    Thank you in advance.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Clearing empty rows

    Try:
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,723

    Re: Clearing empty rows

    This work perfect! Thank you so much.

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Clearing empty rows

    You are very welcome.

  5. #5
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,723

    Re: Clearing empty rows

    I am sorry...

    Forgot to mention. I have titles from row 1-5 and my entry normally starts in 6 row.

    What do i need to change in the code? Cuz when I click the button, it deletes the row 1-5.

    Thank you

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Clearing empty rows

    Try:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,723

    Re: Clearing empty rows

    Hi,

    Ok... the code works for a while. But when I added the Data Validation in H Column, then the error message appeared "X400". See attached.

    Sorry... Thank you so much.
    Attached Files Attached Files

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Clearing empty rows

    Try removing the apostrophe to the left of
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,723

    Re: Clearing empty rows

    Hi,

    The codes work with the data validation but what happened to the question I had in #1. It looked like it did not work the edited code.

    In the attachment example, there is no entry in row A11 but it should moved to row10 if i clicked the button. The only thing that it should be deleted row is when the rows are totally empty or there is not entry in any of the cells. If the cells in the rows have an entry then it should not be deleted and should be moved from the empty rows.

    Thank in advance.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,723

    Re: Clearing empty rows

    Please Login or Register  to view this content.

  11. #11
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Clearing empty rows

    May be:
    PHP Code: 
    Option Explicit
    Sub Kaboom
    ()
        
    Dim lr&, cAs VariantAs Long
        lr 
    Columns("A:H").SpecialCells(xlCellTypeLastCell).Row ' last used row of range A - H, not only of col A
        v = Range("A6:A" & lr).Value
        For Each c In ActiveSheet.Shapes
            If InStr(1, c.OnAction, "Kaboom", 0) > 0 Then
                c.Placement = xlFreeFloating
                Exit For
            End If
        Next
        For i = lr To 6 Step -1
            If Len(Cells(i, 1)) = 0 And Cells(i, 1).End(xlToRight).Column = Columns.Count Then ' 
    delete rows where len column A =and right next cell is last col XFD
                Rows
    (i).Delete
            End 
    If
        
    Next
    End Sub 
    Quang PT

  12. #12
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,723

    Re: Clearing empty rows

    Hi Bebo,
    The code you provided worked in the sample worksheet and it does exactly the one I want it.
    It was actually perfect but when I transferred the code in my original worksheet it did not work.
    It's probably because it's so many things going on my my workbook. There some vba codes that was already in the workbook.

    When I click the button, It's just circling around and it stays there for a long time that seems its reading something.

    Thank you.

  13. #13
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Clearing empty rows

    Try:
    Please Login or Register  to view this content.

+ 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. clearing empty cells in export files
    By Chefgirl30 in forum Excel General
    Replies: 5
    Last Post: 02-06-2019, 05:43 PM
  2. Clearing Blank (but not Empty) cells
    By jon687 in forum Excel General
    Replies: 5
    Last Post: 01-04-2018, 12:09 PM
  3. Delete Empty Rows and empty columns from the word table
    By mvneema in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2014, 10:51 AM
  4. Help with Clearing Rows according to Value
    By NewToVBA_23 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-03-2013, 04:28 PM
  5. Clearing entire row contents if cell is empty in a particular column
    By sgk18 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-01-2012, 02:36 AM
  6. ExcelDiet and clearing empty cells
    By drgogo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2010, 05:25 AM
  7. Autofilter/delete empty rows is deleting non-empty rows!
    By oOarthurOo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-05-2010, 12:31 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