Results 1 to 2 of 2

Thread: Error inputting formula using macro

  1. #1

    Error inputting formula using macro



    Register for a FREE account, and/
    or Log in to avoid these ads!

    I have created a formula that works perfectly when manually entered into a cell, the formula is as follows:

    =IFERROR(IF(ISNA(VLOOKUP('Worksheet2'!B:B,'Worksheet3'!A:A,1,FALSE)),IF(AND('Worksheet2'!C:C<>"",IF('Worksheet2'!C:C<=$J$4,'Worksheet2'!B:B,"")),IF('Worksheet2'!C:C>=$I$4,'Worksheet2'!B:B,""),""),""),"")

    However, I want to assign a macro that will input this formula into a cell, for instance cell H2, I created this:

    Range("H2").Formula = "=IFERROR(IF(ISNA(VLOOKUP('Worksheet2'!B:B,'Worksheet3'!A:A,1,FALSE)),IF(AND('Worksheet2'!C:C<>"",IF('Worksheet2'!C:C<=$J$4,'Worksheet2'!B:B,"")),IF('Worksheet2'!C:C>=$I$4,'Worksheet2'!B:B,""),""),""),"")"

    However, when I attempt to run this macro, I get the error "Run-time error '1004': Application-defined or object-defined error"

    What could be the issue?

  2. #2
    Magician NoS's Avatar
    Join Date
    Jan 2013
    Location
    British Columbia
    Posts
    824
    Articles
    0
    Excel Version
    Excel 2010
    godda love those double quotes..... try this

    Range("H2").Formula = "=IFERROR(IF(ISNA(VLOOKUP('Worksheet2'!B:B,'Worksheet3'!A:A,1,FALSE)),IF(AND('Worksheet2'!C:C<>" & """""" & ",IF('Worksheet2'!C:C<=$J$4,'Worksheet2'!B:B," & """""" & ")),IF('Worksheet2'!C:C>=$I$4,'Worksheet2'!B:B," & """""" & ")," & """""" & ")," & """""" & ")," & """""" & ")"

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •