Solved

Excel-VB Application-Defined or Object-Defined error

Posted on 2013-01-09
4
335 Views
Last Modified: 2013-01-09
I have a line in an Excel 2010 vb code that is throwing a Run-time error 1004:

Application-defined or objexct-defined error

The line of code is:

Range("E21").Formula = "=IFERROR(LOOKUP(2,1/(('Earn Roll'!A:A='Department Workcenter Load'!A21)*('Earn Roll'!B:B='Department Workcenter Load'!C21)),'Earn Roll'!C:C),"")"

the equation returns the desired result if when I enter it in cell E21 of worksheet 'Department Workcenter Load'

Any help would be appreciated.
0
Comment
Question by:Scamquist
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 34

Accepted Solution

by:
Norie earned 250 total points
ID: 38759915
You need to double up the quotes in the formula.
Range("E21").Formula = "=IFERROR(LOOKUP(2,1/(('Earn Roll'!A:A='Department Workcenter Load'!A21)*('Earn Roll'!B:B='Department Workcenter Load'!C21)),'Earn Roll'!C:C),"""")"

Open in new window

0
 
LVL 9

Assisted Solution

by:TazDevil1674
TazDevil1674 earned 250 total points
ID: 38759934
I would suggest that and double quotes inside the actual formula are replaced with chr(34) - example below.  You might want to try .Value instead of .Formula too

Range("E21").Formula = "=IFERROR(LOOKUP(2,1/(('Earn Roll'!A:A='Department Workcenter Load'!A21)*('Earn Roll'!B:B='Department Workcenter Load'!C21)),'Earn Roll'!C:C)," & chr(34) & chr(34) & ")"

Open in new window


Hope this helps
0
 
LVL 1

Author Closing Comment

by:Scamquist
ID: 38760154
Thank you.  Both answers worked.
0
 
LVL 1

Author Comment

by:Scamquist
ID: 38760156
Both answers did work.  Thank you.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question