+ Reply to Thread
Results 1 to 2 of 2

Error entering formula into cell through macro

  1. #1
    Registered User
    Join Date
    03-15-2013
    Location
    Canada
    MS-Off Ver
    MS Office 2013 Professional
    Posts
    18

    Error entering formula into cell through macro

    Part of a macro I have written has the following code:
    Please Login or Register  to view this content.
    When I run this macro, I get the following error, which directs me to ^that line in the code:

    Run time error '1004':
    Application-defined or object-defined error

    What is wrong with the code?

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Error entering formula into cell through macro

    You have several problems in your formula. An attempt to set an invalid formula in a cell will raise error 1004.

    What do you mean by these expressions:
    Team1RoundSort[First]
    [Position]

    These are not valid Excel formula syntax. Are you trying to refer to named ranges? If so, you want
    Team1RoundSort!First
    Position

    Also, function COUNTIF has too many arguments:
    COUNTIF(INDIRECT("G"&ROW()&":"&"G"&(ROWS(position)+2)),$F3:$F23,0)

    COUNTIF takes range,criteria, but you have range,range,criteria.

    Because the formula is hard-coded--you are not using any variables to build this formula--you should implement the formula directly in your worksheet to test it, then once you are successful simply copy it into your code.
    Last edited by 6StringJazzer; 08-11-2013 at 10:20 AM. Reason: Further diagnosis on the COUNTIF problem
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] #Value error on entering a formula using VBA
    By TC1980 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-12-2013, 09:03 AM
  2. Entering a formula with macro into cell
    By bobo1000 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-23-2012, 09:03 AM
  3. Entering formula in cell using macro
    By Pingvinfan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2009, 04:48 AM
  4. #NAME Error when entering formula
    By flyhigh515 in forum Excel General
    Replies: 6
    Last Post: 11-24-2008, 03:27 PM
  5. Replies: 2
    Last Post: 10-04-2006, 11:37 AM

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