Goodmorning everyone,
I'm a beginner with VBA trying out various things. Atm I'm trying to get a formula to be placed inside a row of cells but I'm encountering a problem. I use a number of variables that seem to be causing a problem in my formula. I already changed some things I found on this site (like changing from ActiveCell to Range and adding the rr and r variables.
However this doesn't fix the error message I'm getting. I looked up the error but didn't quite understand what the meaning was.
Could anyone tell me what is causing the problem in my code but also what the error message means so I can try and debug it myself.
With F8 I already made sure that all variables were filled in correctly. the error comes from the Range(r).Formula line.
Sub Zoeker()
Sheets("Invoer").Select
NumRows_Gist = Range("A3", Range("A3").End(xlDown)).Rows.Count
NumRows_Vand = Range("I3", Range("I3").End(xlDown)).Rows.Count
For x = 1 To NumRows_Vand
Dim r As String
rr = Range("O" & 2 + x).Row
r = "O" & Range("O" & 2 + x).Row
Range(r).Formula = "=IF(IF(IFERROR(VLOOKUP(I" & rr & ";$A$3:$B$" & NumRows_Gist & ";2;FALSE);'Niet vorige upload') <> 'Niet vorige upload'; VLOOKUP(I" & rr & ";$A$3:$B$" & NumRows_Gist & ";2;FALSE) + J" & rr & "; 'correct') <> 0; ''; '0')"
Next
End Sub