I have done a lot of searching and trial and error and I still haven't been able to find an answer for my question.
I would like to fill a range in sheet2 with a formula that refers to a dynamic range in sheet1. I have used the piece of code that I have pasted below, and it works perfectly so far.
Dim rng as Range
Dim x as Integer
Set rng=worksheets(sheet2).Range("J6:J9")
x = 21
With sheet1
LastCol = .Cells(21, .Columns.Count).End(xlToLeft).Column
End With
For Each c In rng
c.Formula = "=sheet1!" & Cells(j, LastCol).Address
j = j + 1
Next c
My problem is that this code creates an absolute reference, and I need a relative (or mixed) since I need to be able to do some "dragging" of cells later on. I have tried using formulaR1C1, but I can't get it to work with dynamic ranges.
I would be very happy if anyone can help me and if you need me to explain anything feel free to ask :)