+ Reply to Thread
Results 1 to 2 of 2

error '1004' "application defined or object defined error" when pasting formula with macro

Hybrid View

  1. #1
    Registered User
    Join Date
    03-24-2013
    Location
    Apple Valley, MN
    MS-Off Ver
    Excel 2010
    Posts
    29

    error '1004' "application defined or object defined error" when pasting formula with macro

    When I run the following macro
    Dim w As Integer
        For w = 6 To 39
            Range("C" & w).Formula = "=IF(LEN($B" & w & ")>=1,"" ""&VLOOKUP(LEFT($B" & w & "), '[Ch Name index.xls]Family Names'!$A$1:$B$13017,2,0), "")&IF(LEN($B" & w & ")>=2,"" ""&VLOOKUP(MID($B" & w & ",2,1), '[Ch Name index.xls]all Characters'!$A$1:$B$15041,2,0), "")&IF(LEN($B" & w & ")>=3,"" ""&VLOOKUP(MID($B" & w & ",3,1), '[Ch Name index.xls]all Characters'!$A$1:$B$15041,2,0),"")&IF(LEN($B" & w & ")=4,"" ""&VLOOKUP(MID($B" & w & ",4,1), '[Ch Name index.xls]all Characters'!$A$1:$B$15041,2,0),"")"
        Next w
                Range("D6:G39").Select
                Selection.ClearContents
                Range("D6:G39").FormulaR1C1 = ChrW(&H221A)
        Dim x As Integer
        For x = 6 To 39
            Range("P" & x).Formula = "=IF(ISERROR($C" & x & "),"",LOOKUP(COUNTIF(D" & x & ":G" & x & "," & A & ")*1+SUM(D" & x & ":G" & x & "),$BC$8:$BC$16,$BD$8:$BD$16))"
        Next x
        For x = 6 To 39
            Range("W" & x).Formula = "=LOOKUP(COUNTIF(D" & x & ":G" & x & "," & A & ")*1+SUM(D" & x & ":G" & x & "),$BC$8:$BC$16,$BE$8:$BE$16)"
        Next x
        For x = 6 To 39
            Range("AK" & x).Formula = "=LOOKUP(COUNTIF(D" & x & ":G" & x & "," & A & ")*1+SUM(D" & x & ":G" & x & "),$BC$8:$BC$16,$BF$8:$BF$16)"
        Next x
        For x = 6 To 39
            Range("AL" & x).Formula = "=LOOKUP(COUNTIF(D" & x & ":G" & x & "," & A & ")*1+SUM(D" & x & ":G" & x & "),$BC$8:$BC$16,$BG$8:$BG$16)"
        Next x
        Range("K9").Select
    It hangs up at this line
    Range("C" & w).Formula = "=IF(LEN($B" & w & ")>=1,"" ""&VLOOKUP(LEFT($B" & w & "), '[Ch Name index.xls]Family Names'!$A$1:$B$13017,2,0), "")&IF(LEN($B" & w & ")>=2,"" ""&VLOOKUP(MID($B" & w & ",2,1), '[Ch Name index.xls]all Characters'!$A$1:$B$15041,2,0), "")&IF(LEN($B" & w & ")>=3,"" ""&VLOOKUP(MID($B" & w & ",3,1), '[Ch Name index.xls]all Characters'!$A$1:$B$15041,2,0),"")&IF(LEN($B" & w & ")=4,"" ""&VLOOKUP(MID($B" & w & ",4,1), '[Ch Name index.xls]all Characters'!$A$1:$B$15041,2,0),"")"
    and tells me "error '1004' application defined or object defined error"

    What do I need to change?

  2. #2
    Valued Forum Contributor wenqq3's Avatar
    Join Date
    04-01-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    868

    Re: error '1004' "application defined or object defined error" when pasting formula with m

    Range("C" & w).Formula = "=IF(LEN($B" & w & ")>=1,"" ""&VLOOKUP(LEFT($B" & w & "), '[Ch Name index.xls]Family Names'!$A$1:$B$13017,2,0), "")&IF(LEN($B" & w & ")>=2,"" ""&VLOOKUP(MID($B" & w & ",2,1), '[Ch Name index.xls]all Characters'!$A$1:$B$15041,2,0), "")&IF(LEN($B" & w & ")>=3,"" ""&VLOOKUP(MID($B" & w & ",3,1), '[Ch Name index.xls]all Characters'!$A$1:$B$15041,2,0),"")&IF(LEN($B" & w & ")=4,"" ""&VLOOKUP(MID($B" & w & ",4,1), '[Ch Name index.xls]all Characters'!$A$1:$B$15041,2,0),"")"
    Possible write your code in normal way, as you type in cell.
    You can put w as 6. Thanks.
    -If the problem is solved, please mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved".

    -Always upload a workbook before start your question
    To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

    +++ If my answer(s) helped you, please add me reputation by click on * +++

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1