My spreadsheet has a header row on row 4. The macro below is suppose to put a formula on row 5 in columns F and K and fill down to the last row of data. The macro is doing this, but after it adds the formula in F on row 5, it then copies down the HEADER row on row 4, wiping out the formulas. It is doing the same exact thing for column K. Why is this happening?
Sheets("NJN Lic Exp").Select
Dim UsdRws As Long
UsdRws = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Range("F5").Select
ActiveCell.Formula2R1C1 = _
"=MID(CELL(""filename"",R[-4]C[-5]),FIND(""]"",CELL(""filename"",R[-4]C[-5]))+1,255)"
Range("f5:f" & UsdRws).FillDown
Range("K5").Select
ActiveCell.FormulaR1C1 = _
"=CONCAT(RC[-3],"": "",R4C9,"":"","" "",RC[-2],"","",R4C10,"":"","" "",RC[-1])"
Range("k5:k" & UsdRws).FillDown
Sheets("NJN Lic Exp").Select
Dim UsdRws As Long
UsdRws = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Range("F5").Select
ActiveCell.Formula2R1C1 = _
"=MID(CELL(""filename"",R[-4]C[-5]),FIND(""]"",CELL(""filename"",R[-4]C[-5]))+1,255)"
Range("f5:f" & UsdRws).FillDown
Range("K5").Select
ActiveCell.FormulaR1C1 = _
"=CONCAT(RC[-3],"": "",R4C9,"":"","" "",RC[-2],"","",R4C10,"":"","" "",RC[-1])"
Range("k5:k" & UsdRws).FillDown