+ Reply to Thread
Results 1 to 12 of 12

Recorded Formula Gives Compile Error

  1. #1
    Forum Contributor
    Join Date
    08-19-2009
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    585

    Recorded Formula Gives Compile Error

    Hello all,

    I have recorded the following formula to use it in my code.
    It keeps on giving an error (Expected: end of statement) on the line marked in red.
    Any ideas

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Recorded Formula Gives Compile Error

    Keep this in a cell

    A1 Cell

    IFERROR(IF(AND(COUNTIF(INDIRECT("DBS!HA"&$AP25&":ZZ"&$AP25);M$9)>0;IFERROR(OFFSET(INDEX(INDIRECT("DBS!HA"&$AP25&":ZZ"&$AP25);MATCH(M$9;INDIRECT("DBS!HA"&$AP25&":ZZ"&$AP25);0));0;1)="X";FALSE));OFFSET(INDEX(INDIRECT("DBS!HA"&$AP25&":ZZ"&$AP25);MATCH(M$9;INDIRECT("DBS!HA"&$AP25&":ZZ"&$AP25);0));0;2);IFERROR(INDEX(INDIRECT("ROS!"&ADDRESS(10;MATCH(INDIRECT("DBS!"&ADDRESS($AP25;MATCH(LARGE(INDIRECT($AQ25);COUNTIF(INDIRECT($AQ25);">"&M$9)+1);INDIRECT($AQ25);0)+39));INDIRECT($AR25);0)+5)&":"&ADDRESS((MATCH(REPT("z";255);INDIRECT("ROS!"&ADDRESS(10;MATCH(INDIRECT("DBS!"&ADDRESS($AP25;MATCH(LARGE(INDIRECT($AQ25);COUNTIF(INDIRECT($AQ25);">"&M$9)+1);INDIRECT($AQ25);0)+39));INDIRECT($AR25);0)+5)&":"&ADDRESS(79;MATCH(INDIRECT("DBS!"&ADDRESS($AP25;MATCH(LARGE(INDIRECT($AQ25);COUNTIF(INDIRECT($AQ25);">"&M$9)+1);INDIRECT($AQ25);0)+39));INDIRECT($AR25);0)+5)))+9);MATCH(INDIRECT("DBS!"&ADDRESS($AP25;MATCH(LARGE(INDIRECT($AQ25);COUNTIF(INDIRECT($AQ25);">"&M$9)+1);INDIRECT($AQ25);0)+39));INDIRECT($AR25);0)+5));MOD(M$9-1+OFFSET(INDIRECT("DBS!"&ADDRESS($AP25;MATCH(LARGE(INDIRECT($AQ25);COUNTIF(INDIRECT($AQ25);">"&M$9)+1);INDIRECT($AQ25);0)+39));0;1)-LARGE(INDIRECT($AQ25);COUNTIF(INDIRECT($AQ25);">"&M$9)+1);ROUNDUP((MATCH(REPT("z";255);INDIRECT("ROS!"&ADDRESS(10;MATCH(INDIRECT("DBS!"&ADDRESS($AP25;MATCH(LARGE(INDIRECT($AQ25);COUNTIF(INDIRECT($AQ25);">"&M$9)+1);INDIRECT($AQ25);0)+39));INDIRECT($AR25);0)+5)&":"&ADDRESS(79;MATCH(INDIRECT("DBS!"&ADDRESS($AP25;MATCH(LARGE(INDIRECT($AQ25);COUNTIF(INDIRECT($AQ25);">"&M$9)+1);INDIRECT($AQ25);0)+39));INDIRECT($AR25);0)+5))))/7;0)*7)+1;1);""));"")


    Refer that cell in your macro code

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Contributor
    Join Date
    08-19-2009
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    585

    Re: Recorded Formula Gives Compile Error

    Hello SixthSense, This looks very promosing but gives an error "Application-defined or object-defined error"
    And will the references automatically adjust when populating a range with it?

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Recorded Formula Gives Compile Error

    I tested it and it is working fine

    If your formula is constructed in that way (to auto adjust) by way of relative reference then surely it will auto adjust

  5. #5
    Forum Contributor
    Join Date
    08-19-2009
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    585

    Re: Recorded Formula Gives Compile Error

    If I use it like this, I get the same result in all cells.
    I'd like it to adjust the references like it would have done when used in a code.

    Please Login or Register  to view this content.

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Recorded Formula Gives Compile Error

    What is the value of range A1?

    Because you have not used any equal symbol in front of A1.

    Refer my post #2 content once again.

  7. #7
    Forum Contributor
    Join Date
    08-19-2009
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    585

    Re: Recorded Formula Gives Compile Error

    I added the equal sign back just to see what happens.
    There was no error but now getting the same results in all cells
    (I have used relative references in my formula)

  8. #8
    Forum Contributor
    Join Date
    08-19-2009
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    585

    Re: Recorded Formula Gives Compile Error

    I also tried this:

    Please Login or Register  to view this content.
    Value in A1:

    Please Login or Register  to view this content.
    But results in the same error as before

  9. #9
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Recorded Formula Gives Compile Error

    Your formula is workine fine only thing you have to do is make it as relative reference

  10. #10
    Forum Contributor
    Join Date
    08-19-2009
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    585

    Re: Recorded Formula Gives Compile Error

    I'm not sure why but the problem seems to result from the use of "=" in my code.
    It does not replace the # into an = sign in the following example.
    It removes the # sign though?

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    08-19-2009
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    585

    Re: Recorded Formula Gives Compile Error

    I'm not sure why but the problem seems to result from the use of "=" in my code.
    It does not replace the # into an = sign in the following example.
    It removes the # sign though?

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    08-19-2009
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    585

    Re: Recorded Formula Gives Compile Error

    I solved it in the following way.

    Please Login or Register  to view this content.
    A1 houses the formula including the equal sign.

    Thanks again for your help SixthSense!

+ 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] Compile Error in Hidden Module and Compile Error: Can't find project or library
    By Taislin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-10-2013, 07:03 PM
  2. Cell references error with recorded Conditional Formatting (Formula) macro
    By nlexcel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-23-2012, 01:38 PM
  3. Recorded macro gets formula error
    By CityMPLSEmpolyee in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-10-2012, 09:28 AM
  4. [SOLVED] formula array gives compile error
    By R..VENKATARAMAN in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-06-2006, 08:35 AM
  5. [SOLVED] VBAProject name compile error, not defined at compile time
    By Matthew Dodds in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-13-2005, 03:20 PM

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