Identify header, filter and fill content

Nagoo

New Member
Joined
Jul 2, 2015
Messages
30
Hello All,

I would like to have a macro which finds the header "Blogs" in the input sheet --> Then apply the filter to identify "NA" and Blanks --> Then replace the blanks and "NA" with "No" --> then take out the filter.

Note: Somtimes Header "Blogs" might not be available in the sheet for which macro needs to skip this process and exit.

Thanks for your valuable suggestions
 
Last edited:

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try this in a copy of your workbook
- amend "Input Sheet"
- as requested code filters on blanks and "NA" (ie the code looks for text "NA" NOT the error #N/A)
- alternative line is included (commented out)

Code:
Sub blogs()
    Dim rng As Range, blogs As Range
    Set blogs = Sheets("[B]Input Sheet[/B]").Cells.Find("Blogs", lookat:=xlWhole)
    If blogs Is Nothing Then End
[COLOR=#000080][I]'insert row to guarantee current region correctly set[/I][/COLOR]
    blogs.EntireRow.Insert
    Set rng = blogs.CurrentRegion
    Set rng = blogs.Resize(rng.Rows.Count)
[COLOR=#000080][I]'filter[/I][/COLOR]
    rng.AutoFilter
    rng.AutoFilter Field:=1, Criteria1:="=NA", Operator:=xlOr, Criteria2:="="
         [COLOR=#ff0000]'rng.AutoFilter Field:=1, Criteria1:="=#N/A", Operator:=xlOr, Criteria2:="="[/COLOR]
[COLOR=#000080][I]'amend values[/I][/COLOR]
    rng.SpecialCells(xlCellTypeVisible).Value = "No"
    blogs.Value = "Blogs"
[COLOR=#000080][I]'reset filter and delete previously added row[/I][/COLOR]
    rng.AutoFilter
    blogs.Offset(-1).EntireRow.Delete
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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