Please Help, Adding Formula to Cell with VBA

jestes0623

New Member
Joined
May 21, 2015
Messages
3
Please see if you can tell me where I have messed up. I keep getting object not defined:

Sub Clear_Add()


Application.ScreenUpdating = False

Range("D4").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Date Of Error]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0)),"""
Range("G4").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Date Of Error]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0)),"""
Range("D6").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Supervisors Name]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0)),"""
Range("G6").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Error description]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0)),"""
Range("D7").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Employee Name]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0)),"""
Range("G7").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Employee '#]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0)),"""
Range("C10").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Explanation of Error]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0)),"""
Range("C13").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Explanation of Correct Process]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0)),"""
Range("D15").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Date Discussed]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0)),"""
Range("C24").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Supervisors Planned Followup (What and When)]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0)),"""
Range("G33") = ("")

Application.ScreenUpdating = True


End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Just a wild guess from my side.
There are 2 possible error areas: either the macro is not working or the generated formulas don't work.
You can check if the formulas end up in the cells, e.g. verify D4 if the formula is there.

I think the latter part of your lines are incorrect and you should replace ,0)),""" with ,0))," & chr(34) & chr(34) & ")"
chr(34) will give you a double quote, so after running the macro the latter part of the formulas shoud read ,0)),"")

Hope this helps.
 
Upvote 0
Wow Thank you so much. It worked perfect! So here is what it ended up looking like in case any others are have this issue:

Sub Clear_Add()


Application.ScreenUpdating = False

Range("D4").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Date Of Error]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0))," & Chr(34) & Chr(34) & ")"
Range("G4").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Date Of Error]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0))," & Chr(34) & Chr(34) & ")"
Range("D6").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Supervisors Name]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0))," & Chr(34) & Chr(34) & ")"
Range("G6").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Error description]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0))," & Chr(34) & Chr(34) & ")"
Range("D7").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Employee Name]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0))," & Chr(34) & Chr(34) & ")"
Range("G7").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Employee '#]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0))," & Chr(34) & Chr(34) & ")"
Range("C10").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Explanation of Error]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0))," & Chr(34) & Chr(34) & ")"
Range("C13").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Explanation of Correct Process]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0))," & Chr(34) & Chr(34) & ")"
Range("D15").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Date Discussed]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0))," & Chr(34) & Chr(34) & ")"
Range("C24").Formula = "=IFERROR(INDEX(EAF_Report_Table[[#All],[Supervisors Planned Followup (What and When)]],MATCH('EAF Add'!$G$33,EAF_Report_Table[[#All],[Error '#]],0))," & Chr(34) & Chr(34) & ")"
Range("G33") = ("")

Application.ScreenUpdating = True


End Sub
 
Upvote 0

Forum statistics

Threads
1,203,453
Messages
6,055,530
Members
444,794
Latest member
HSAL

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top