+ Reply to Thread
Results 1 to 11 of 11

Code sometimes works and sometimes not

  1. #1
    Registered User
    Join Date
    10-13-2020
    Location
    Curitiba, Brasil
    MS-Off Ver
    10
    Posts
    12

    Code sometimes works and sometimes not

    Hello! I wrote a code that sometimes it runs fine and sometimes it do not get the values. I'd like to know what I'm doing wrong.

    Please Login or Register  to view this content.

  2. #2
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Code sometimes works and sometimes not

    what do you mean by it does not get values? can you post the line(s) of code that are causing the issue(s)?

  3. #3
    Registered User
    Join Date
    10-13-2020
    Location
    Curitiba, Brasil
    MS-Off Ver
    10
    Posts
    12

    Re: Code sometimes works and sometimes not

    Hi, tks for helping! This code should get values from a workbook and print in other. Sometime it does print the values and sometimes not. I do belive the errors must be in this lines

    Please Login or Register  to view this content.

  4. #4
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Code sometimes works and sometimes not

    what's the issue? the autofill lines? or this?
    Please Login or Register  to view this content.
    have you stepped through the routine when it doesn't produce what you want? you step line by line via the F8 key.

  5. #5
    Registered User
    Join Date
    10-13-2020
    Location
    Curitiba, Brasil
    MS-Off Ver
    10
    Posts
    12

    Re: Code sometimes works and sometimes not

    The autofill I suppose. When I do step by step it works properly.

  6. #6
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Code sometimes works and sometimes not

    that doesn't make sense. if you stepped through it, one line at a time, then obviously that was a time that it was working for you. you said yourself that sometimes it works, sometimes it doesn't. so, can you replicate the error and tell us when it fails? what did you do at that time? any special happenings during that time?

  7. #7
    Registered User
    Join Date
    10-13-2020
    Location
    Curitiba, Brasil
    MS-Off Ver
    10
    Posts
    12

    Re: Code sometimes works and sometimes not

    I don't know. Looks like the vba didn't finish to execute the loops before go to next step. This are the images when the code fails and when it works. Attachment 699499Attachment 699500

  8. #8
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Code sometimes works and sometimes not

    i can view those images. upload them a different way.....this is what i see:
    Attached Images Attached Images

  9. #9
    Registered User
    Join Date
    10-13-2020
    Location
    Curitiba, Brasil
    MS-Off Ver
    10
    Posts
    12

    Re: Code sometimes works and sometimes not

    Works.jpg

    Don'r work.jpg


    I do belive the autofill is the problem, but I dont know why. In the image "works" autofill corectly get the values from other sheet, when it does no work, it only selects the place where the values should
    appear
    Attached Images Attached Images

  10. #10
    Registered User
    Join Date
    10-13-2020
    Location
    Curitiba, Brasil
    MS-Off Ver
    10
    Posts
    12

    Re: Code sometimes works and sometimes not

    I solved the problem, thanks for the help!

    Please Login or Register  to view this content.
    I do belive the problem was in the first line of this code. I just put the third line in the beggining of the code. As the code starts with the command ActiveCell, it requires an active cell on the worksheet, so, as I didn't select any cell, my autofill was only selecting my parameter, whitout do anything. Not sure the concepts I deduced are right, but the code is running fine now.

  11. #11
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Code sometimes works and sometimes not

    nice job. good luck

+ 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. writing vba code to fill in column of sheet, formula works vba code will not
    By pdx2245 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-28-2019, 05:15 PM
  2. [SOLVED] How code works
    By Potholes in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 07-10-2018, 10:03 AM
  3. How code works
    By Potholes in forum Excel General
    Replies: 3
    Last Post: 07-06-2018, 02:52 AM
  4. Replies: 1
    Last Post: 07-02-2018, 07:32 PM
  5. Replies: 0
    Last Post: 07-05-2017, 09:36 PM
  6. how can i make this code works for multiple links it only works for one link
    By baig123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-12-2014, 08:38 AM
  7. code only works SOMETIMES
    By Piyush in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-21-2005, 11:04 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