+ Reply to Thread
Results 1 to 16 of 16

code does what its supposed to but errors out at the end. Dont know why

  1. #1
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    code does what its supposed to but errors out at the end. Dont know why

    here is my code (what it does it create a formula thats very long).

    It works (meaning that it puts the correct formula in a cell) but error's out at the very end.

    Please Login or Register  to view this content.
    here is what the formula looks like when its done:
    Please Login or Register  to view this content.
    as you can see it's very long. so the macro works by putting the formula in E66, however in the visual basic editor it complains about this line:

    ActiveCell.FormulaR1C1 = a

    any thoughts about what is causing this line to error out?

    the error is "run time error '1004': Application defined or object defined error"
    Last edited by dmcgov; 06-10-2016 at 12:50 PM. Reason: added error message

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: code does what its supposed to but errors out at the end. Dont know why

    The formula uses A1 refernce style and not R1C1. Try this...

    Range("e66").Formula = a
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: code does what its supposed to but errors out at the end. Dont know why

    Hello dmcgov,

    Try by just removing "ActiveCell.FormulaR1C1 = a" from your Code.

    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  4. #4
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: code does what its supposed to but errors out at the end. Dont know why

    alpha, i tried what you suggested but it errors out on the Range line.

    anything else that i can try?

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: code does what its supposed to but errors out at the end. Dont know why

    Replace

    Range("e66").Select
    ActiveCell.FormulaR1C1 = a

    with

    Range("e66")=a

  6. #6
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: code does what its supposed to but errors out at the end. Dont know why

    AB33, same error, it fails on the last line.

  7. #7
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: code does what its supposed to but errors out at the end. Dont know why

    @AB33,

    I have already tested that to no avail.

    Hi dmcgov,

    I notice that your Workbook contains about 57 or more Sheets. In order for us us to properly access your issue please attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

    Regards,
    Last edited by Winon; 06-10-2016 at 02:01 PM. Reason: Removed (or use the paperclip icon)

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: code does what its supposed to but errors out at the end. Dont know why

    No way it fails unless the find function returns nil (False)

    Put this line above line and see what the message says

    MsgBox a

  9. #9
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: code does what its supposed to but errors out at the end. Dont know why

    @AB33,

    Still, no joy.

  10. #10
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: code does what its supposed to but errors out at the end. Dont know why

    i already have the "msgbox a" in my code. what it shows is the formula with one hiccup. let me do a screen snapshot, maybe that will help.

    VBerror.jpg

    Note that "='Control" is on one line by itself and the rest is on a second line. but when i check cell E66, the formula shows up there the way that its supposed to.

    any thoughts?

  11. #11
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: code does what its supposed to but errors out at the end. Dont know why

    Hello dmcgov,

    Sorry, but I will not be able to assist further, without seeing a sample Workbook, as requested in my last post to you.

    Regards.

  12. #12
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: code does what its supposed to but errors out at the end. Dont know why

    I am confused too.
    If the find function is correct, it returns a static value. You are merely copying a static value to E66. Unless the text exceeds 255, I can not see what the issue is. You can not simply assign a value you extract from a find function into another formula in range. Please attach a sample to see what the error is

  13. #13
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: code does what its supposed to but errors out at the end. Dont know why

    ok. i stripped down the file (it was 7Mb) and got it under 1mb.

    so open file, go to "Control budg + Approved COS", examine cell E66. It has the stripped down formula in it. so go ahead and delete the contents of that cell and then run "test". whatever i did to strip down the file now does not copy the formula to E66. but the error will still show up.

    VBerror2.jpg


    msgbox.jpg
    Attached Files Attached Files
    Last edited by dmcgov; 06-10-2016 at 02:54 PM.

  14. #14
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: code does what its supposed to but errors out at the end. Dont know why

    I need to look at the code again, but removing this line appears to work.
    The code keep picking up this line 'a = a + "='Control_Budget'!E66+"
    and this line is not valid as it has "="

    Please Login or Register  to view this content.

  15. #15
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: code does what its supposed to but errors out at the end. Dont know why

    I need to look at the code again, but removing this line appears to work.
    The code keep picking up this line 'a = a + "='Control_Budget'!E66+"
    and this line is not valid as it has "="

    Please Login or Register  to view this content.

  16. #16
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: code does what its supposed to but errors out at the end. Dont know why

    nah i fixed it. was wondering if the last "+" of the string was causing problem so i changed my code like so:

    Please Login or Register  to view this content.
    now it works like it was intended.

+ 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. Tommorow EXAMS still dont know the code
    By Laloke12 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-22-2014, 04:45 AM
  2. Please Help. Got Logic but dont quite understand how to Code it . Thanks :)
    By simplificated in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-27-2013, 06:25 PM
  3. [SOLVED] Need help fixing a formula, currently returning errors and dont know how to fix it
    By 33CDonnelly in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-15-2013, 04:17 PM
  4. code dont read the line
    By Kristofferdk in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-15-2012, 07:10 AM
  5. Please help me with this code ...i dont understand
    By umliu37 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-06-2011, 02:02 AM
  6. Replies: 1
    Last Post: 12-14-2009, 05:20 PM
  7. Errors-I dont understand why
    By Buzzaro in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-28-2007, 11:59 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