Adding a Column C to this Macro

jexcel3

Board Regular
Joined
Nov 24, 2007
Messages
153
Can someone help me adjust this macro to check for N/As in Column C and Column D. I would like to have the macro delete the entire row if there is a N/A in column C and/or D. The N/A is a text, not an excel error. Any ideas?



Code:
Sub CheckD()
Dim lastrow As Long, i As Long
Application.ScreenUpdating = False
Application.Calculation = xlManual
With ActiveSheet
    lastrow = .Cells(Rows.Count, 3).End(xlUp).Row
    For i = lastrow To 1 Step -1
         If .Range("D" & i).Value = "N/A" Then .Rows(i).Delete
    Next i
End With
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
Try:

Code:
Sub CheckD()
Dim lastrow As Long, i As Long
Application.ScreenUpdating = False
Application.Calculation = xlManual
With ActiveSheet
    lastrow = .Cells(Rows.Count, 3).End(xlUp).Row
    For i = lastrow To 1 Step -1
         If .Range("C" & i).Value = "N/A" Or .Range("D" & i).Value = "N/A" Then .Rows(i).Delete
    Next i
End With
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
End Sub

Denis
 
Upvote 0

Forum statistics

Threads
1,191,684
Messages
5,987,993
Members
440,124
Latest member
dippy_egg

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top