I am trying to write vba code that writes a formula to a cell. The formula is to hlookup with the array being fixed, on another worksheet, and with size depending on variables already defined.
Here is the relevant part of the code (the variables have already been defined and are integers):
Range("C2").Select
ActiveCell.Formula = "=hlookup(A2,Visits!Range("C2",Cells(" & rowsforlook & ", " & rowsforauto & " + 1))," & rowsforlook & " - 1)"
I have checked that there are no problems with the variables. I have realised that I haven't $fixed the array because I am not sure how to do this. I also think the page reference "Visits!" is probably not correct, but the code did not select an array even without this. The array I am trying to use is the selected region that would appear if I typed
Range("C2",Cells(" & rowsforlook & ", " & rowsforauto & " + 1)).Select
Thanks.