+ Reply to Thread
Results 1 to 19 of 19

Macros Run time error - please help

  1. #1
    Registered User
    Join Date
    01-09-2017
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2010
    Posts
    8

    Macros Run time error - please help

    Hi all, i am the lucky one in my company that apparently volunteered to do reports for everyone.
    I have set up a macros to do several look ups and to create a final csv file used to upload into a CRM.

    I have re-written the macros several times and when its first finished it works ok but when i do an update days later, i get the run time error '1004'
    Application-defined or object defined error

    When i debug the file it goes here - please help ???
    Run time error debug.jpg

  2. #2
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Macros Run time error - please help

    What's the active cell that command is trying to change?
    Is it locked?

    That looks very much like recorded code. If you post the entire subroutine in [code] tags we can tidy it up for a start.

  3. #3
    Registered User
    Join Date
    01-09-2017
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2010
    Posts
    8

    Re: Macros Run time error - please help

    i hope this is what you are after.
    It looks up 3 other excel sheets and performs a vlookup - that's it.
    As mentioned, it will work after originally creating the macros, then a day later it will not.
    Last edited by Lethal27; 01-10-2017 at 07:24 PM.

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Macros Run time error - please help

    Quote Originally Posted by BellyGas View Post
    f you post the entire subroutine in [code] tags we can tidy it up for a start.
    You may have missed this part of the last response. Please adjust accordingly.

    Administrative Note:
    • We would love to continue to help you with your query, but first, before we can proceed…
    • Please see Forum Rule #3 about the proper use of code tags and adjust accordingly...
    HTH
    Regards, Jeff

  5. #5
    Registered User
    Join Date
    01-09-2017
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2010
    Posts
    8

    Re: Macros Run time error - please help

    Even after reading the code tags - still not 100% sure what i need to provide or how to find it. Clearly not an expert.

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Macros Run time error - please help

    You post your code, then highlight your code and select the # in the toolbar above.

    In the end...

    [ code ]This is where your code goes [ /code ]

    Note: Without the spaces

    As in the example

    [ code ]
    Sub HelloWorld()
    Msgbox "HelloWorld"
    End Sub
    [ /code ]

  7. #7
    Registered User
    Join Date
    01-09-2017
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2010
    Posts
    8

    Re: Macros Run time error - please help

    Hope i have it right - don't want to waste people's time but i really want to find a solution - thanks jeffreybrown

    Please Login or Register  to view this content.

  8. #8
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Macros Run time error - please help

    Would be a lot better If you could upload an example of your workbook with dummy data but shows the exact data structure. And show what your data should look like after macro runs. Looks like your using 2 or three other workbooks in your vlookup.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  9. #9
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macros Run time error - please help

    you have a lot of redundant code there

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

    Please Login or Register  to view this content.
    and it should avoid any issues with activecell
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  10. #10
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macros Run time error - please help

    your code runs like a snail without the 3 files being open
    Please Login or Register  to view this content.
    with all 3 files open before you run the code...it seems to run a lot faster

  11. #11
    Registered User
    Join Date
    01-09-2017
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2010
    Posts
    8

    Re: Macros Run time error - please help

    Hi Guys, even with a tidy up, it still doesn't work and yes i always run the macros with the 3 files open.
    I have added all 5 files that i work with (dummy info)
    1 is the download csv - the one i run the macros in
    2 - 4 is the look up info
    5 is the copy / save as file i use to upload.

  12. #12
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macros Run time error - please help

    sorry Rookie mistake

    vba cannot output #N/A so if your first vlookup gives you #n/a it will crash
    which is why it probably worked before but not now

    need to go back to drawing board on how to circumvent

  13. #13
    Registered User
    Join Date
    01-09-2017
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2010
    Posts
    8

    Re: Macros Run time error - please help

    Is there any other way to change the #N/A to 0 so it will work in the macros? i have tried a few different ways of replacing the #N/A but maybe in the macros i could find all #N/A and replace with 0? Would this work or is it based on the result of #N/A that the macros doesn't like?

  14. #14
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macros Run time error - please help

    duplication

  15. #15
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macros Run time error - please help

    your worksheet name changed

    change this
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    full code now is
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    01-09-2017
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2010
    Posts
    8

    Re: Macros Run time error - please help

    I have copied the code and it works but i will try it again tomorrow - petty sure it will return the same error - Hopefully not. i also downloaded my 3 other files and run the macros on them as well.
    Thanks in advance

  17. #17
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macros Run time error - please help

    If you use VBA the use of Excelformulae like 'Vlookup' is redundant and slowing down the calculations dramatically.



  18. #18
    Registered User
    Join Date
    01-09-2017
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2010
    Posts
    8

    Re: Macros Run time error - please help

    Has worked today where previously it didn't so i would say problem solved - thanks to all who helped.

  19. #19
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Macros Run time error - please help

    You are very welcome, but suppose I did not help much at all. There are plenty of truly smart folks about VBA other than me...

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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] ORA-03113: end-of-communication channel Error after some time while running VBA macros
    By manojn in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-30-2016, 01:05 AM
  2. [SOLVED] Macros must be enabled code failing with Run Time Error 57121
    By leaning in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-30-2016, 11:25 AM
  3. [SOLVED] Getting Run time error '9' from macros in similar workbooks.
    By garysallred in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-02-2014, 08:38 AM
  4. Below CDO macros displays run time error 13
    By ashfaq sayed in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-08-2013, 08:11 PM
  5. [SOLVED] Auto run macros at a given time error
    By mukeshbaviskar in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-20-2013, 10:06 AM
  6. Replies: 1
    Last Post: 05-05-2010, 01:33 PM
  7. Macros giving Run-time error '9' on all machines except mine
    By WinterCoast in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2008, 12:56 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