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

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
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,214,666
Messages
6,120,806
Members
448,990
Latest member
rohitsomani

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