I'm trying to build a macro that inserts a value into a specific cell of table by looking up a row value and looking up a column value and using that to determine the cell to paste to. I am quite new to VBA so I'm not really sure what I'm doing.
This is what I have so far:
Name=Sheets("Input").Range("C5")
Week=Sheets("Input").Range("C19")
copyCell=Sheets("Input").Range("C18")
pasteCell = Application.Index(Sheets("Resources").Range("B2:AZ50"),Application.Match(Week,Sheets("Resources").Range("A2:A50"),0),Application.Match(Name,Sheets("Resources").Range("B1:AZ1"),0))
copyCell.Copy
pasteCell.PasteSpecial PasteValues
I keep getting a runtime error object required but I'm not quite sure what I'm doing wrong...
Any help would be appreciated!
UPDATE
This is the table which the cell is being pasted too (this table is not the real table just an example so as to hide the names in the table but it looks exactly the same except that the real table starts on the first row).
And this is the input page:
Note: I have since put in more code surrounding the week variable:
If WorksheetFunction.CountA(Sheets("Input").Range("C19")) = 0 Then
Week = Sheets("Input").Range("C20").Value
Else
Week = Sheets("Input").Range("C19").Value
End If
Very much appreciate the help you guys are giving!