I am currently working on a macro that needs to copy a INDEX function from a cell, that has varying information and run it. Eg. the function can be either "=INDEKSI(voy!A1:E4;1;0)" or "=INDEKSI(kto!A1:E4;1;0)". But when I run this macro it only uses either one of those two. Here is the code:
Range("N1").Select
Selection.Copy
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A3:E3").Select
Application.CutCopyMode = False
Selection.FormulaArray = "=INDEX(kto!R[-2]C:R[1]C[4],1,0)"
Selection.AutoFill Destination:=Range("A3:E14"), Type:=xlFillDefault
Range("A3:E14").Select
End Sub
Is there any way to fix this line:
Selection.FormulaArray = "=INDEX(kto!R[-2]C:R[1]C[4],1,0)"
Edit:
This macros point is to pull vehicle information from another tab. The INDEX function varies based on what the user picks from the drop down menu, with this: "=IFS(A1="voy";"=INDEKSI(voy!A1:E4;1;0)";A1="kto";"=INDEKSI(kto!A1:E4;1;0)")". This "IFS" function is located in N1. Then it needs to copy only the values form that cell, paste them, select 5 cells (A3-E3), click the formula bar and press CTRL + SHIFT + ENTER.
I'm really beginner with these, and I'm not sure if this can even work this way.