I'm creating a macro where I could apply my formulas to selected column (this is the working month-year, example Nov-2022). I have initial code where the specific column for that month will be selected however I'm stuck as to what code I can use to apply the formula that will start and apply to row 11 to row 17 and row 20 to row 26 of that selected column. Do you have any codes where I can apply the formulas to these selected cells?
Codes to Find the Column selected in drop down (Month-Year):
Sub FindAddressColumn()
'Updateby Extendoffcie
Dim xRg As Range
Dim xRgUni As Range
Dim xFirstAddress As String
Dim xStr As Variant
On Error Resume Next
xStr = Range("C5").Value
Set xRg = Range("D8:AA31").Find(xStr, , xlValues, xlWhole, , , True)
If Not xRg Is Nothing Then
xFirstAddress = xRg.Address
Do
Set xRg = Range("A1:P1").FindNext(xRg)
If xRgUni Is Nothing Then
Set xRgUni = xRg
Else
Set xRgUni = Application.Union(xRgUni, xRg)
End If
Loop While (Not xRg Is Nothing) And (xRg.Address <> xFirstAddress)
End If
xRgUni.EntireColumn.Select
End Sub
Formulas that needs to apply:
My range below is specific to Column N since my working month is placed in Column N.
How will I change the formula so it will be dynamic, for example I would like to work for December which is placed in Column O? Same formula but different Column.
Range("N9").Select
ActiveCell.FormulaR1C1 = _
"=IFNA(VLOOKUP(RC[-12],'Working File'!C[21]:C[22],2,0), "" "")"
Range("N10").Select
ActiveCell.FormulaR1C1 = _
"=IFNA(VLOOKUP(RC[-12],'Working File'!C[21]:C[22],2,0), "" "")"
Range("N11").Select
ActiveCell.FormulaR1C1 = _
"=IFNA(VLOOKUP(RC[-12],'Working File'!C[21]:C[22],2,0), "" "")"
Range("N12").Select
ActiveCell.FormulaR1C1 = _
"=IFNA(VLOOKUP(RC[-12],'Working File'!C[21]:C[22],2,0), "" "")"
Range("N13").Select
ActiveCell.FormulaR1C1 = _
"=IFNA(VLOOKUP(RC[-12],'Working File'!C[21]:C[22],2,0), "" "")"
Range("N14").Select
ActiveCell.FormulaR1C1 = _
"=IFNA(VLOOKUP(RC[-12],'Working File'!C[21]:C[22],2,0), "" "")"
Range("N15").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-6]C:R[-1]C)"
Range("N18").Select
ActiveCell.FormulaR1C1 = _
"=IFNA(XLOOKUP(""Total Fixed Fee / System Implementation Current WIP to Bill"",Current!C[-13],Current!C[-3],),"" "")"
Range("N19").Select
ActiveCell.FormulaR1C1 = _
"=IFNA(VLOOKUP(RC[-12],'Working File'!C[25]:C[26],2,0),"" "")"
Range("N20").Select
ActiveCell.FormulaR1C1 = _
"=IFNA(VLOOKUP(RC[-12],'Working File'!C[25]:C[26],2,0),"" "")"
Range("N21").Select
ActiveCell.FormulaR1C1 = _
"=IFNA(VLOOKUP(RC[-12],'Working File'!C[25]:C[26],2,0),"" "")"
Range("N22").Select
ActiveCell.FormulaR1C1 = _
"=IFNA(VLOOKUP(RC[-12],'Working File'!C[25]:C[26],2,0),"" "")*-1"
Range("N23").Select
ActiveCell.FormulaR1C1 = _
"=IFNA(VLOOKUP(RC[-12],'Working File'!C[25]:C[26],2,0),"" "")*-1"
Range("N24").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-6]C:R[-1]C)"
Range("N25").Select
End Sub

I would use a loop and reletive location i.e.