Most valuable professional
  • Hot Topics

Excel Delete rows if specific columns contain cells with "N/A"

Hi, I would like to set up a button where cells with "N/A" in specific columns will then delete the relevant row - the columns are Z, AA and AB. When I use the code below it does not seem to work. The code is the following: Sub Button3_Click() 'Declare variables Dim rngFound As Range 'Used for the find loop Dim rngDel As Range 'Used to store matching rows Dim strFirst As String 'Used to store the first cell address of the find loop to prevent infinite loop 'Search for #N/A in column C Set rngFound = Columns("Z").Find("#N/A", Cells(Rows.Count, "Z"), xlValues, xlWhole) 'Make sure something was found If Not rngFound Is Nothing Then 'Found something, record first cell address strFirst = rngFound.Address 'Start loop Do 'Check if cells in column Z, AA, and AB are all #N/A If Cells(rngFound.Row, "Z").Text = "#N/A" _

This question generated 41 answers. To proceed to the answers, click here.

This thread is current as of July 9, 2014.

For more resources for Microsoft Excel:

This article includes the following tags:

  • Excel
  • Microsoft Excel