Multiple cells with multiple criteria

vangoori

New Member
Joined
Sep 4, 2014
Messages
6
Hi All,

i am looking for VBA code for below mentioned criteria

Column "A1" to column "E1" i have data ... i need find out the

"#N/A" and "Zero" in that list and delete.


ABCDE
1#N/A251045
230#N/A245
22231230
252451252
#N/A524524
03#N/A24#N/A

<colgroup><col width="64" span="5" style="width:48pt"> </colgroup><tbody>
</tbody>

Thanks,
Vangoori.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Hi All,

i am able to write code for each and every columns...(seprate code each column)....


Sub multiplefiltercriteria()


Range("a1").Select
ActiveSheet.Range("$A$1:$E$7").AutoFilter Field:=1, Criteria1:="=0", _
Operator:=xlOr, Criteria2:="=#N/A"
Selection.ClearContents

Range("B1").Select
ActiveSheet.Range("$A$1:$E$7").AutoFilter Field:=1, Criteria1:="=0", _
Operator:=xlOr, Criteria2:="=#N/A"
Selection.ClearContents



End Sub


till Column E ...but i don't want to write code for each column....can any help me on this.... ?


Thanks,
Vangoori.
 
Upvote 0
try this. data in sheet1. copy sheet1 to sheet2 before running macro so that the old data is available if something goes wrong.

Code:
Sub test()
Dim r As Range, c As Range
Worksheets("sheet1").Activate
Set r = Range("A1").CurrentRegion
For Each c In r
If IsError(c) Then c = ""
If c = 0 Then c = ""
Next c


End Sub
 
Upvote 0
Hi Venkat,

first of all ..i would like to thanks for your time .....code is working perfect.

if possible could please explain me how the code is working ,,

Thanks for your help.

Vangoori.
 
Upvote 0
It loops through each cell of the data and if it is error(#N/A) it is changed to blank
similarly if it is 0. I tried using "replace" method it did not work.
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,861
Members
449,052
Latest member
Fuddy_Duddy

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
Back
Top