0

I have a spreadsheet with a load of values in and a button.In the code button I have the following VBA code

If Range("N2").Value = "100" Then
Rows ("2:2").Select
Selection.Delete
 End if

The idea is that if 100 is placed in that row then that row will be deleted.But obviously there will be problems if I have loads of rows,this will mean loads of "IFs" My question is this,is there any way this could be done with a loop.So I could jsut loop through all the rows and if the conditions are met then that Row will be deleted.In the If statement above I have to specify the rows selected,so how would a loop do this?? Any help greatly appreciated. kind regards j

Community
  • 1
  • 1

1 Answers1

3

Set a range and do the following loops

For Each row In rng.Rows
  For Each cell in row.Cells
    'Do Something
  Next cell
Next row
ruedi
  • 5,365
  • 15
  • 52
  • 88