Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Getting error 1004 trying to write formula in cell

In a macro, I wanted to be able to update a formula. I manually updated the
formula on the sheet and it works fine. I simply copied the formula from the
sheet and put it in quotes see below, but I get an error

"Application-defined or object-defined error"


Sheets("test").Range("A1").Formula = "=IF(ISERROR(VLOOKUP($AE6,'Change
Report 6.0'!$C$20:$G$61,AG$4,FALSE)),"",VLOOKUP($AE6,'Cha nge Report
6.0'!$C$20:$G$61,AG$4,FALSE))"

The Help on the error seems to suggest I tried to cause an error, clearly
this is not my intention. Any ideas?

--
Trefor
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Getting error 1004 trying to write formula in cell


Hello Trefor,

Is the Formula all on one line? if you break it you must use the line
continuation character (Underscore) preceded by a space at the end of
the line. If you don't, it won't compile.

Example:
If your code really looks like this, it won't run...

Sheets("test").Range("A1").Formula = "=IF(ISERROR(VLOOKUP($AE6,'Change
Report 6.0'!$C$20:$G$61,AG$4,FALSE)),"",VLOOKUP($AE6,'Cha nge Report
6.0'!$C$20:$G$61,AG$4,FALSE))"

If it has the line continuation characters it will...

Sheets("test").Range("A1").Formula = "=IF(ISERROR(VLOOKUP($AE6,'Change
_
Report 6.0'!$C$20:$G$61,AG$4,FALSE)),"",VLOOKUP($AE6,'Cha nge Report _
6.0'!$C$20:$G$61,AG$4,FALSE))"

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=487497

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default Getting error 1004 trying to write formula in cell

Change the empty quotations in the formula ("") to empty double quotations
(""""). This is a requirement when quotation marks are themselves contained
within quotation marks.

Regards,
Greg

"Trefor" wrote:

In a macro, I wanted to be able to update a formula. I manually updated the
formula on the sheet and it works fine. I simply copied the formula from the
sheet and put it in quotes see below, but I get an error

"Application-defined or object-defined error"


Sheets("test").Range("A1").Formula = "=IF(ISERROR(VLOOKUP($AE6,'Change
Report 6.0'!$C$20:$G$61,AG$4,FALSE)),"",VLOOKUP($AE6,'Cha nge Report
6.0'!$C$20:$G$61,AG$4,FALSE))"

The Help on the error seems to suggest I tried to cause an error, clearly
this is not my intention. Any ideas?

--
Trefor

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Getting error 1004 trying to write formula in cell

Greg,

Spot on, many thanks.

--
Trefor


"Greg Wilson" wrote:

Change the empty quotations in the formula ("") to empty double quotations
(""""). This is a requirement when quotation marks are themselves contained
within quotation marks.

Regards,
Greg

"Trefor" wrote:

In a macro, I wanted to be able to update a formula. I manually updated the
formula on the sheet and it works fine. I simply copied the formula from the
sheet and put it in quotes see below, but I get an error

"Application-defined or object-defined error"


Sheets("test").Range("A1").Formula = "=IF(ISERROR(VLOOKUP($AE6,'Change
Report 6.0'!$C$20:$G$61,AG$4,FALSE)),"",VLOOKUP($AE6,'Cha nge Report
6.0'!$C$20:$G$61,AG$4,FALSE))"

The Help on the error seems to suggest I tried to cause an error, clearly
this is not my intention. Any ideas?

--
Trefor

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Getting error 1004 trying to write formula in cell

Leith,

Many thanks for your fedback. It was all on one line, just the way this
systems works. Greg nailed it, it was double quotes.

--
Trefor


"Leith Ross" wrote:


Hello Trefor,

Is the Formula all on one line? if you break it you must use the line
continuation character (Underscore) preceded by a space at the end of
the line. If you don't, it won't compile.

Example:
If your code really looks like this, it won't run...

Sheets("test").Range("A1").Formula = "=IF(ISERROR(VLOOKUP($AE6,'Change
Report 6.0'!$C$20:$G$61,AG$4,FALSE)),"",VLOOKUP($AE6,'Cha nge Report
6.0'!$C$20:$G$61,AG$4,FALSE))"

If it has the line continuation characters it will...

Sheets("test").Range("A1").Formula = "=IF(ISERROR(VLOOKUP($AE6,'Change
_
Report 6.0'!$C$20:$G$61,AG$4,FALSE)),"",VLOOKUP($AE6,'Cha nge Report _
6.0'!$C$20:$G$61,AG$4,FALSE))"

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=487497




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Getting error 1004 trying to write formula in cell

Greg,

Do you know why the following code errors?

Sheets("test").Range("J1").Formula = "=IF(C9="""","TBA",C9)"

--
Trefor


"Trefor" wrote:

Greg,

Spot on, many thanks.

--
Trefor


"Greg Wilson" wrote:

Change the empty quotations in the formula ("") to empty double quotations
(""""). This is a requirement when quotation marks are themselves contained
within quotation marks.

Regards,
Greg

"Trefor" wrote:

In a macro, I wanted to be able to update a formula. I manually updated the
formula on the sheet and it works fine. I simply copied the formula from the
sheet and put it in quotes see below, but I get an error

"Application-defined or object-defined error"


Sheets("test").Range("A1").Formula = "=IF(ISERROR(VLOOKUP($AE6,'Change
Report 6.0'!$C$20:$G$61,AG$4,FALSE)),"",VLOOKUP($AE6,'Cha nge Report
6.0'!$C$20:$G$61,AG$4,FALSE))"

The Help on the error seems to suggest I tried to cause an error, clearly
this is not my intention. Any ideas?

--
Trefor

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Getting error 1004 trying to write formula in cell

You missed a couple of quotes when you doubled them up:

Sheets("test").Range("J1").Formula = "=IF(C9="""",""TBA"",C9)"

(surrounding TBA)


Trefor wrote:

Greg,

Do you know why the following code errors?

Sheets("test").Range("J1").Formula = "=IF(C9="""","TBA",C9)"

--
Trefor

"Trefor" wrote:

Greg,

Spot on, many thanks.

--
Trefor


"Greg Wilson" wrote:

Change the empty quotations in the formula ("") to empty double quotations
(""""). This is a requirement when quotation marks are themselves contained
within quotation marks.

Regards,
Greg

"Trefor" wrote:

In a macro, I wanted to be able to update a formula. I manually updated the
formula on the sheet and it works fine. I simply copied the formula from the
sheet and put it in quotes see below, but I get an error

"Application-defined or object-defined error"


Sheets("test").Range("A1").Formula = "=IF(ISERROR(VLOOKUP($AE6,'Change
Report 6.0'!$C$20:$G$61,AG$4,FALSE)),"",VLOOKUP($AE6,'Cha nge Report
6.0'!$C$20:$G$61,AG$4,FALSE))"

The Help on the error seems to suggest I tried to cause an error, clearly
this is not my intention. Any ideas?

--
Trefor


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
How to write a formula that will prevent appearance ERROR MESSAGE Huriiii Excel Worksheet Functions 1 June 22nd 05 12:45 AM
Protect Sheet but enable cell ranges giving Error 1004 Unable to set William[_4_] Excel Programming 3 August 11th 04 09:09 PM
Error when using macro to write formula to cell Patti[_3_] Excel Programming 3 April 2nd 04 07:49 PM
Excel Formula - Error 1004 - Bug? Mistake? Markus Wilthaner Excel Programming 3 December 17th 03 02:25 AM


All times are GMT +1. The time now is 10:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"