HI intelligent people,
I am trying to set up a macro that contains a formula in cell G7. This formula includes a range with the relevant data that shows up in a different column each month. The way I am thinking is that I search for the title of the data and then select the 300 rows below this cell,. This range is then SET as ABC (Dim as range). Then I use ABC and include it in the formula below BUT no luck in getting any results so far. The problem I have with this formula is that the results I get in cell "G7" is #NAME? and not the number I am trying to fetch.
Your assistance would be greatly appreciated please.
I am trying to set up a macro that contains a formula in cell G7. This formula includes a range with the relevant data that shows up in a different column each month. The way I am thinking is that I search for the title of the data and then select the 300 rows below this cell,. This range is then SET as ABC (Dim as range). Then I use ABC and include it in the formula below BUT no luck in getting any results so far. The problem I have with this formula is that the results I get in cell "G7" is #NAME? and not the number I am trying to fetch.
Your assistance would be greatly appreciated please.
VBA Code:
Sub Macro5()
'
Dim ABC As Range
Range("a1:az8").Select
Selection.Find(What:="XYZ", LookIn:=xlValues).Offset(1, 0).Select
Set ABC = Range(Selection, Selection.Offset(300, 0))
Range("G7").select
ActiveCell.Formula2R1C1 = "=INDEX(ABC,(@R7C1:R300C1,R7C16:R300C16,FALSE))"
end sub