My experience of macros and VBA has so far been limited to creating a button to colour in cells so you'll have to excuse this if it's a possible easy fix.
I have a template sheet into which will be pasted data on a weekly basis containing both headers and tasks - I'm looking to filter the headers only, then format these rows and unfilter, automating this using a macro.
I've recorded the following to do this: -
    ActiveSheet.Range("$A$4:$H$413").AutoFilter Field:=2, Criteria1:="="
    ActiveWindow.SmallScroll Down:=-9
    Range("A5:L168").Select
    Range("A168").Activate
    Selection.SpecialCells(xlCellTypeVisible).Select
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 3394611
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    Selection.Font.Bold = True
    Range("I5:L168").Select
    Range("L168").Activate
    Selection.SpecialCells(xlCellTypeVisible).Select
    Selection.ClearContents
    Range("C5:H168").Select
    With Selection.Font
        .Color = -13382605
        .TintAndShade = 0
    End With
    ActiveSheet.Range("$A$4:$H$413").AutoFilter Field:=2
    Range("A4").Select
However this formats the same rows every time the macro is run, and so when different data is pasted into the template (containing headers in different locations) the macro-driven formatting then doesn't pick up the header rows.
Is there any way to adjust the range so that the macro will only be applied to certain cells selected by the user (for example the remaining visible rows when I filter the data)?
 
     
    