This code is working all perfect it finds the column name, but the problem is I am not able to apply formula to the visible cells any suggestion
VBA Code:
Sub fillrejectionflag()
Dim co12 As String, c10find As Range
Dim co13 As String, cc12find As Range
co12 = "Cand. Final Status"
co13 = "Email Flag"
Lastrow = Cells(Rows.Count, 1).End(xlUp).Row + 1
With Worksheets("Candidate Master") '<-- reference your relevant worksheet (change "AF" to your actual worksheet name)
With .Range("A1", .Cells(1, .Columns.Count).End(xlToLeft)) '<-- reference its row 1 cells from column 1 rightwards to last not empty one
Set c10find = .Rows(1).Find(what:=co12, LookIn:=xlValues, lookat:=xlWhole)
Set cc12find = .Rows(1).Find(what:=co13, LookIn:=xlValues, lookat:=xlWhole)
If Not c10find Is Nothing Then '<-- if the header has been found
[B]Range(c10find & Lastrow).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "1" '' Problem is here
Range(cc12find & Lastrow).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "=now()" ''Problem is here[/B]
' do your things
End If
End With
'.AutoFilterMode = False '<-- show all rows back and remove autofilter buttons
End With
End sub