Note that there are some explanatory texts on larger screens.

plurals
  1. PODeleting entire row whose column contains a 0, Excel 2007 VBA
    primarykey
    data
    text
    <p>UPDATE:</p> <p>Alright, so i used the following code and it does what i need it to do, i.e check if the value is 0 and if its is, then delete the entire row. However i want to do this to multiple worksheets inside one workbook, one at a time. What the following code is doing is that it removes the zeros only from the current spreadsheet which is active by default when you open excel through the VBA script. here the working zero removal code:</p> <pre><code>Dim wsDCCTabA As Excel.Worksheet Dim wsTempGtoS As Excel.Worksheet Set wsDCCTabA = wbDCC.Worksheets("Login") Set wsTempGtoS = wbCalc.Worksheets("All_TemporaryDifferences") Dim LastRow As Long, n As Long LastRow = wsTempGtoS.Range("E65536").End(xlUp).Row For n = LastRow To 1 Step -1 If Cells(n, 5).Value = 0 Then Cells(n, 5).EntireRow.Delete End If Next </code></pre> <p>What am i doing wrong? when i do the same thing for another worksheet inside the same workbook it doesnt do anything. I am using the following code to remove zeros from anohter worksheet:</p> <pre><code>Set wsPermGtoS = wbCalc.Worksheets("All_PermanentDifferences") 'delete rows with 0 description Dim LastRow As Long, n As Long LastRow = wsPermGtoS.Range("E65536").End(xlUp).Row For n = LastRow To 1 Step -1 If Cells(n, 5).Value = 0 Then Cells(n, 5).EntireRow.Delete End If Next </code></pre> <p>Any thoughts? or another way of doing the same thing?</p> <p>ORIGINAL QUESTION:</p> <p>I want to delete all the rows which have a zero in a particular column. I am using the following code but nothing seems to happen:</p> <pre><code> CurrRow = (Range("E65536").End(xlUp).Row) For Count = StartRow To CurrRow If wsDCCTabA.Range("E" &amp; Count).Value = "0" Then wsDCCTabA.Rows(Count).Delete End If Next </code></pre> <p><code>StartRow</code> contains the starting row value <code>CurrRow</code> contains the row value of the last used row</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload