Home > Back-end >  Excel VBA: Filtered range in DataBodyRange
Excel VBA: Filtered range in DataBodyRange

Time:11-25

I'm trying to set a formula into a specific range of a dynamic table.

The point is that a different formula calculation is stored in the first row of the column than in the other rows. I want to store a different formula from line 2 to the last line.

I dont want to use loops. I think that the solution can be more cool.

How can I select the range from row 2 of the DataBodyRange to the last row?

My last try looks like:

    With ActiveSheet.ListObjects("disp_plan")
        .DataBodyRange.Cells(1, 9).Formula = "=R17C17 R3C2"
        .ListColumn(9).DataBodyRange.Range(.Cells(2), .Cells(.DataBodyRange.Rows.Count)).FormulaR1C1 = "=R[-1]C RC[-2]"
    End With

CodePudding user response:

With ActiveSheet.ListObjects("disp_plan").ListColumns(9).DataBodyRange
    .Cells(1, 1).FormulaR1C1 = "=R17C17 R3C2"
    .Offset(1).Resize(.Rows.Count - 1).FormulaR1C1 = "=R[-1]C RC[-2]"
End With
  • Related