Hi, I have the following code
Sub formula()
Dim LastRow As Long
With ActiveSheet
LR = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Dim LastCol As Integer
With ActiveSheet
LC = .Cells(1, .Columns.Count).End(xlToLeft).Column
End With
Range("B2:AEL2").formula = "=TR(R[-1]C[0],""TR.CompanyMarketCap"",""SDate=#1"",,R2C1)"
Range("B3:AEL3").formula = "=TR(R[-2]C[0],""TR.CompanyMarketCap"",""SDate=#1"",,R3C1)"
Range("B4:AEL4").formula = "=TR(R[-3]C[0],""TR.CompanyMarketCap"",""SDate=#1"",,R4C1)"
Range("B5:AEL5").formula = "=TR(R[-4]C[0],""TR.CompanyMarketCap"",""SDate=#1"",,R5C1)"
Range("B6:AEL6").formula = "=TR(R[-5]C[0],""TR.CompanyMarketCap"",""SDate=#1"",,R6C1)"
End Sub
I would like to repeat the formula from
Range("B2:AEL2").formula = "=TR(R[-1]C[0],""TR.CompanyMarketCap"",""SDate=#1"",,R2C1)"
until the last row
Range("B LastRow: AEL LastRow").formula = "=TR(R[-LastRow+1]C[0],""TR.CompanyMarketCap"",""SDate=#1"",,LastRowC1)"
Can anyone please help me write a loop for the above formula.
my reference cells are are ranges from from A2:A119 also B1:AEL1
Sub formula()
Dim LastRow As Long
With ActiveSheet
LR = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Dim LastCol As Integer
With ActiveSheet
LC = .Cells(1, .Columns.Count).End(xlToLeft).Column
End With
Range("B2:AEL2").formula = "=TR(R[-1]C[0],""TR.CompanyMarketCap"",""SDate=#1"",,R2C1)"
Range("B3:AEL3").formula = "=TR(R[-2]C[0],""TR.CompanyMarketCap"",""SDate=#1"",,R3C1)"
Range("B4:AEL4").formula = "=TR(R[-3]C[0],""TR.CompanyMarketCap"",""SDate=#1"",,R4C1)"
Range("B5:AEL5").formula = "=TR(R[-4]C[0],""TR.CompanyMarketCap"",""SDate=#1"",,R5C1)"
Range("B6:AEL6").formula = "=TR(R[-5]C[0],""TR.CompanyMarketCap"",""SDate=#1"",,R6C1)"
End Sub
I would like to repeat the formula from
Range("B2:AEL2").formula = "=TR(R[-1]C[0],""TR.CompanyMarketCap"",""SDate=#1"",,R2C1)"
until the last row
Range("B LastRow: AEL LastRow").formula = "=TR(R[-LastRow+1]C[0],""TR.CompanyMarketCap"",""SDate=#1"",,LastRowC1)"
Can anyone please help me write a loop for the above formula.
my reference cells are are ranges from from A2:A119 also B1:AEL1