I posted this problem a few days ago, here.
Now that I understand the problem a little better, I’m posting it again (hopefully a little clearer)
This line in the code causes a “not enough memory” error:
Sheets("Merged Data").Range(Temp).FormulaR1C1 = _
"=OFFSET(Y!R1C[" & -LCA & "],MATCH(RC1,Y!R1C1:R" & LRMERGE & "C1,0)-1,0)"
Is it possible to do this without using as much memory?
I’m stuck, so I appreciate all feedback! 
This is the code with the values that result in a memory error. The full code is in the link above.
Sub Merge_Data()
'Merges the data (rows) with identical Unique-ID in a new sheet. First X, then Y.
Application.ScreenUpdating = False
Dim LC1 As Long
Dim LCB As Long
Dim MySheetName As String
MySheetName = "Merged Data"
Sheets("X").Copy After:=Sheets("X")
ActiveSheet.Name = MySheetName
'Sheet "Merged Data" is identical to sheet "X"
LR1 = 138938 'Last row in sheet "X"
LR2 = 250106 'Last row in sheet "Y"
LC1 = 105 'Last column in sheet "X"
ColLetter = DA 'column 105 = DA
LC2 = 45 'Last column in sheet "Y"
LCA = 106 'Last column in sheet "X" + 1 (Finds first empty column in the new sheet "Merged Data")
LCB = 107 'Last column in sheet "X" + 2 (Finds second empty column in the new sheet "Merged Data")
ColLetter_2 = DC 'column 107 = DC
LRMERGE = 250106 'The biggest of LR1 and LR2
Sheets("Merged Data").Range("A1:" & ColLetter & LC1).Value = Sheets("X").Range("A1:" & ColLetter & LC1).Value
'Is there any reason to keep this line?
Temp = "" & ColLetter_2 & "1:" & Cells(LRMERGE, LC1 + LC2).Address
'Finds the range where the data from sheet "Y" is inputted (in sheet "Merged Data")
Sheets("Merged Data").Range(Temp).FormulaR1C1 = _
"=OFFSET(Y!R1C[" & -LCA & "],MATCH(RC1,Y!R1C1:R" & LRMERGE & "C1,0)-1,0)"
'Looks through column "A" in sheet "Y" to find a match in column "A" in sheet "Merged Data"
'If there is a match, the row from "Y" is inputted into Column DC in the matched row (in "Merged Data").
Sheets("Merged Data").Range(Temp).Value = Sheets("Merged Data").Range(Temp).Value
'Is there any reason to keep this line?
End Sub
(I can't attach files for some reason)
Bookmarks