Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Runtime error 1004 when trying to insert formula in cells

I have a sheet with some numbers in some cells, while other celles are empty. Now I try to replace the numbers with a certain formula, but it returns a runtime error 1004, Application-defines og obeject-defined error.

The macro looks like this:

Sub FyldUdfyldte()

Dim Indhold As String
Indhold = InputBox("Type needed formula"")

For Each c In Selection.Cells
If Not IsEmpty(c) Then c.Value = Indhold
Next c

End Sub

The formula looks like this

=IF(VLOOKUP($A31,Opslag!$A:$M,F$1,FALSE)0,VLOOKUP ($A31,Opslag!$A:$M,F$1,FALSE),"")


"Opslag" is another sheet, from where to get new numbers.

Any ideas?

Jan
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Runtime error 1004 when trying to insert formula in cells



Indhold = InputBox("Type needed formula")



For Each c In Selection

If Not IsEmpty(c) Then c.Formula = Indhold

Next c

End Sub


Claus - I have aldready tried that, but get the same runtime error.

Jan
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Runtime error 1004 when trying to insert formula in cells

Den søndag den 5. oktober 2014 14.11.07 UTC+2 skrev Claus Busch:

Thank You. FormulaLocal did the trick. I should have thought of that.

Jan

















Regards

Claus B.

--

Vista Ultimate / Windows7

Office 2007 Ultimate / 2010 Professional




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Runtime error 1004 when trying to insert formula in cells

Hi Claus

You solution of using FormulaLocal Work nicely when I treid to insert this formula in the inputbox

=HVIS(LOPSLAG($A31;Opslag!$A:$M;F$1;FALSK)0;LOPSL AG($A31;Opslag!$A:$M;F$1;FALSK);"")

but it fails with an "Application defined or objectdefined error" in this line

If Not IsEmpty(c) Then c.FormulaLocal = Indhold

when I try with the formula below

=HVIS(HVIS(ER.FEJL(LOPSLAG($B1147;'JK-prisfil'!$C:$HG;DV$1;FALSK));LOPSLAG($B1147;'2015p riser'!$B:$HG;DV$1;FALSK);LOPSLAG($B1147;'JK-prisfil'!$C:$HG;DV$1;FALSK))=0;AFRUND(LOPSLAG($B11 47;'2015priser'!$B:$HG;DV$2;FALSK);0);AFRUND(HVIS( ER.FEJL(LOPSLAG($B1147;'JK-prisfil'!$C:$HG;DV$1;FALSK));LOPSLAG($B1147;'2015p riser'!$B:$HG;DV$1;FALSK);LOPSLAG($B1147;'JK-prisfil'!$C:$HG;DV$1;FALSK));0))

is there a lenght restriction on FormulaLocal or what elese can be wrong?

Jan
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
unable to protect cells in macro sheet b/c runtime error 1004 rldjda Excel Worksheet Functions 1 March 20th 08 08:28 PM
runtime 1004 error on deleting rows with blank cells Janis Excel Programming 5 July 18th 07 09:38 PM
Runtime 1004 error -- insert method of range class failed. tish Excel Discussion (Misc queries) 1 June 1st 07 04:04 PM
Runtime 1004 error when insert. mikewild2000[_33_] Excel Programming 2 March 8th 06 10:48 PM
Runtime 1004 error when insert. mikewild2000[_32_] Excel Programming 0 March 8th 06 07:21 PM


All times are GMT +1. The time now is 08:36 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"