jdautel
09-20-2016, 12:48 PM
Here's a simple piece of code I wrote to delete all rows in my spreadsheet that had the value N in the A cell. When I run it from the VBA window it only does one iteration of the for loop (i.e.) only deleting one row. When I run it from the excel screen with the macro it deletes ALL the rows with the value N in their A cell. Why does it only run one iteration in the visual basic window?
Option Explicit
Sub deletemorerows()
Dim cell As Range
For Each cell In Range("A2:A2000")
If cell.Value = "N" Then
cell.EntireRow.Delete
End If
Next cell
End Sub
Also, I understand that I could just sort and delete all the N values; however, I try to use VBA whenever I can to get more and more familiar with it.
Thanks in advance for any responses!
Option Explicit
Sub deletemorerows()
Dim cell As Range
For Each cell In Range("A2:A2000")
If cell.Value = "N" Then
cell.EntireRow.Delete
End If
Next cell
End Sub
Also, I understand that I could just sort and delete all the N values; however, I try to use VBA whenever I can to get more and more familiar with it.
Thanks in advance for any responses!