+ Reply to Thread
Results 1 to 4 of 4

improve delete rows macro

  1. #1
    Registered User
    Join Date
    05-30-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2003
    Posts
    28

    improve delete rows macro

    The macro below correctly deletes the row if the cells in the range have a 0 value. I am trying to add code that would not delete the row even if the cells in the range had zeros if there is a value in column A. I can't figure it out.



    Sub delete0()
    Dim found As Boolean: found = False
    Dim lastRow As Long: lastRow = Range("h" & Rows.Count).End(xlUp).Row
    Application.Calculation = xlCalculationManual

    For j = lastRow To 9 Step -1
    For i = 6 To 9 And Not found
    If Cells(j, i) <> 0 Then found = True
    Next i
    If Not found Then
    Rows(j & ":" & j).delete Shift:=xlUp
    End If
    found = False
    Next j
    Application.Calculation = xlCalculationAutomatic

    End Sub

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: improve delete rows macro

    Try this:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-30-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2003
    Posts
    28

    Cool Re: improve delete rows macro

    Thanks this works

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: improve delete rows macro

    Hi, Bpd,

    Your opening post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ 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 Find Rows With Duplicates, Compare Cells, And Delete Rows. - Excel
    By Kwame001 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-26-2013, 10:41 AM
  2. [SOLVED] Need improve speed of transpose & delete row shiftUp (11 minutes)
    By tuongtu3 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 04-18-2013, 10:05 PM
  3. Macro to delete certain columns and delete rows based on time in another column
    By beepbeep27 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2012, 11:47 AM
  4. How to improve macro performance for copying rows from one sheet to another
    By jonny_chanook in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-05-2011, 09:41 AM
  5. Improve code to delete cells with a value of 0
    By richinlaf31 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-23-2008, 11:51 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