+ Reply to Thread
Results 1 to 10 of 10

Run Time 1004 on pasting formula into cell.

  1. #1
    Registered User
    Join Date
    06-17-2013
    Location
    Greenfield, IN
    MS-Off Ver
    Excel 2007
    Posts
    70

    Run Time 1004 on pasting formula into cell.

    I am getting a runtime 1004 error (Application-defined or object-defined error) with the following code:
    *Note - If I cut and paste the formula directly into F2 it works just fine.

    Thank you ahead of time!!!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Run Time 1004 on pasting formula into cell.

    Does it change anything if you put .value after FormulaR1C1?

  3. #3
    Registered User
    Join Date
    05-08-2012
    Location
    Golden, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    77

    Re: Run Time 1004 on pasting formula into cell.

    Instead of Activecell.formulaR1C1 = ...try
    Activecell.Value = ...

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Run Time 1004 on pasting formula into cell.

    Hi, floydian,

    don´t use FormulaR1C1 when using A1 notation - AFAIK it should read
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  5. #5
    Registered User
    Join Date
    06-17-2013
    Location
    Greenfield, IN
    MS-Off Ver
    Excel 2007
    Posts
    70

    Re: Run Time 1004 on pasting formula into cell.

    Interesting: I did a "Record Macro" and it changed the forumla and it now works. I don't understand how it does... but it does.
    The new wormula:

    Please Login or Register  to view this content.
    Based on the posts above: Is there a "Better" way to do what I did or is the fix I posted just as efficient?

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Run Time 1004 on pasting formula into cell.

    Hi, floydian,

    because the macro recorder used R1C1 notation.

    Ciao,
    Holger

  7. #7
    Registered User
    Join Date
    06-17-2013
    Location
    Greenfield, IN
    MS-Off Ver
    Excel 2007
    Posts
    70

    Re: Run Time 1004 on pasting formula into cell.

    Which might as well be in French.
    I'm trying to learn.... but it's coming slowly.

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Run Time 1004 on pasting formula into cell.

    Hi, floydian,

    let´s take E5 (in VBA I would use Range("E5") for that). If you go into the options in Excel you will find R1C1 notation which would switch the column headers to display the number of the columns as opposed to the letters right now. R5C5 would be the equivalent to E5 (Column 5, Row 5, in VBA Cells(5, 5) or Cells(5, "E") as the row number always needs a numeric value while the column may either be letter(s) or a numeric value).

    HTH,
    Holger

  9. #9
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Run Time 1004 on pasting formula into cell.

    Perhaps this should be another thread, but I'm assuming this is the difference between absolute and relative.

    What points do you use to determine which one you want to use?

    I started in .Net not VBA where these distinctions are less necessary.

  10. #10
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Run Time 1004 on pasting formula into cell.

    Hi, XeRo Solus,

    Perhaps this should be another thread
    Agreed.

    It depends on what I want to do. If filling formulas into cells I would rely on the R1C1 notation which would deliver an absolute cell reference if you use R5C5 meaning E5 and a relative one using R[5]C[5] standing for activecell and offset of 5 rows down and 5 column to the right (negative values would be up and to the left).

    I mostly work with Range which may be set like
    Please Login or Register  to view this content.
    except if I had to loop through columns and rows with non-adjacent cells (if avoiding to build up ranges first or using Arrays with Row numbers and Column letters).

    Any use referring to the original cell may be covered by using Offset like
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    where i is a Long (at least if I were to Dim it). And of course that may be negative values but for A1 it´s hard to imagine that there is a negative column or row (should lead to a run-time error).

    Please check the VBA help for more information on that: go to the VBE, press F2 to get up the Object Catalogue and enter either Cells or Range into the search field and have a read about these items and where they are located in the Excel Application model. Or check out http://support.microsoft.com/kb/291308.

    HTH,
    Holger

+ 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