+ Reply to Thread
Results 1 to 24 of 24

If< 0 problem

  1. #1
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    If< 0 problem

    My code works perfectly, the way I want it to, except when PH equals 0 from a blank cell I do not want that number to be pasted but instead restart the loop at the beginning of the next column(Whatever that column maybe)


    Please Help Me

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: If< 0 problem

    What is this stuff for?

    Please Login or Register  to view this content.
    A lot of things are not clear with your code. This might correct things, then again maybe not. Hard to tell without more info
    Please Login or Register  to view this content.
    Last edited by stnkynts; 03-27-2015 at 05:42 PM.

  3. #3
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    Re: If< 0 problem

    I altered the code a little and got the output to return a blank value of ""
    So now my only issue is...

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

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: If< 0 problem

    Hi mbrandt5,

    Try the following code (tested and working):
    Please Login or Register  to view this content.
    Lewis

  5. #5
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    Re: If< 0 problem

    Unfortunately, I'm having a rough time grasping conditional compiling. I did however get the code to work with a few amount outputs by removing the wait times.

    For work, I'm needing to output between 5,000 to 20,000 entries.

    Excel stopped responding two out of three attempts, but I did work once.

    Also, can this code be easily altered to run in the background so other work can be done simultaneously?



    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: If< 0 problem

    Unfortunately, I'm having a rough time grasping conditional compiling. I did however get the code to work with a few amount outputs by removing the wait times.
    CONDITIONAL COMPILING is a tool to make certain sections of code COMPILE or NOT COMPILE based on the value of a CONDTIONAL COMPILING CONSTANT. When I was testing the code, I did not have access (nor did I want access) to your external program. This allowed me to test the code.
    For additional information see: http://www.utteraccess.com/wiki/inde...iler_Constants

    The code as posted WILL COMPILE all your wait and Sendkey codes.

    For work, I'm needing to output between 5,000 to 20,000 entries.
    Excel stopped responding two out of three attempts, but I did work once.
    Also, can this code be easily altered to run in the background so other work can be done simultaneously?
    The code as written is a resource hog, as it continuously checks for waitTill to expire. Part of your problem may be that you eliminated the calculation of waitTill and the loop will run forever, waiting for a value that has already expired:
    Please Login or Register  to view this content.

    I don't know the sequence of events that is supposed to happen when you issue the SendKeys command. From your earlier code, it appears that you need a time delay after sending the SendKeys command. The time delay code you use now has granularity of 1 second. The Sleep api Command can be used with a granularity of milliseconds. I don't know if that will help you or not.

    Example Using the Sleep command:
    Please Login or Register  to view this content.
    I hope this helps.

    Lewis

  7. #7
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    Re: If< 0 problem

    So, I apologize, I am struggling greatly with this...I've integrated the sleep functionality to the best of my ability, but can't for the life of me figure it out

    If I've altered the code in a way it makes it harder to guide/help me then I dually apologize.

    I am currently getting the error Next without For when Next icolumn occurs



    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    Re: If< 0 problem

    And thanks for explaining conditional compilation...I get it now just not sure if the code placement

  9. #9
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: If< 0 problem

    Try the following code. Excel crashes on my computer if I don't comment out the SendKeys code. It is probably specific to my machine.

    Please Login or Register  to view this content.
    Lewis

  10. #10
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    Re: If< 0 problem

    This will expedite my job exponentially.

    Thank you so much for helping me out.

  11. #11
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    Re: If< 0 problem

    This will expedite my job exponentially.

    Thank you so much for helping me out.

  12. #12
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: If< 0 problem

    I'm glad I was able to help.

    You can change the 1000 value in the Sleep command to anything you want. The lower the number, the faster the code will run. This is fine as long as you don't lose any data.

    Lewis

  13. #13
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    Re: If< 0 problem

    I took your advice...lowered the sleep to 1 millisecond, and if worked great

    I thought though to take some pressure off of excel I would combine all the row values into one row so it represented the number as 5.555556+E54

    Assuming the code needs adjust to process that...I got the run time error "6", and it highlighted
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by mbrandt5; 03-29-2015 at 10:54 PM.

  14. #14
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: If< 0 problem

    I didn't understand your last post if there was a question there.

    You probably need to increase one Sleep value to at least 10 and add DoEvents if you want this to run in the background.

    The runtime error 6 was caused by an integer overflow, which means somehow a row value or column value was too big. That should never have happened.

    Lewis

  15. #15
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    Re: If< 0 problem

    So, I adjusted the sleep to10 which I'll try at 100, but when I remove the decimals so it doesn't show the 555.E46(it still copies as 555.E46)
    How can I get it to copy the actual series of 5s?

  16. #16
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: If< 0 problem

    I thought though to take some pressure off of excel I would combine all the row values into one row so it represented the number as 5.555556+E54
    So, I adjusted the sleep to10 which I'll try at 100, but when I remove the decimals so it doesn't show the 555.E46(it still copies as 555.E46)
    How can I get it to copy the actual series of 5s?
    I apologize, but I don't understand the question. Where specifically is 5.555556+E54 or (if that is not correct, another number), what number (or text) do you want when you see that value, and where do you want that value to go?

  17. #17
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    Re: If< 0 problem

    So, I adjusted the sleep to10 which I'll try at 100, but when I remove the decimals so it doesn't show the 555.E46(it still copies as 555.E46)
    How can I get it to copy the actual series of 5s?
    Another viable option that would suit my needs would be to have sendkey actions of {alt tab}, {UP}, and {alt tab} once more...


    Here is the code up to date...any help is greatly appreciated

    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    Re: If< 0 problem

    Opps didn't see your reply...

    when I output the cell information to notepad excel disregards that I have eliminated the decimals(I believe)

    I would like 5556000 to output 5556000 to notepad(thru alt tab to access the programsend keys)



    It current sends the keys 555.6E4

  19. #19
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: If< 0 problem

    Try implementing the new line in red below:
    Please Login or Register  to view this content.
    Lewis

  20. #20
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    Re: If< 0 problem

    So, that format function did give me integers just not the correct integers...(Tried a few others with no success)

    This was what program 1111111111111111111111 equaled and this is what was output 1111111000000000000000

    Also I am still getting the overflow error 6 even after I change the sleep to 100...

    Unfortunately if that can't, fix the error from occurring the integer output issue wouldn't matter.

    ...If that turns out to be the case then my only other option would be to implement some code that would have sendkey actions of {alt tab}, {UP}, and {alt tab} occur after excel finds a blank cell.

    Because, essentially I need all numbers in a column entered then an {UP} in the other program, then continue in excel at the top of the next row

  21. #21
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    Re: If< 0 problem

    Which you have already answered on my other thread...thank you!

  22. #22
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    Re: If< 0 problem

    Though I am still wondering if it can be done with the other method...
    Is that something you'd be willing to take on?

  23. #23
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: If< 0 problem

    I'm very busy Wed and Thu, but I will take a look at this on Friday. I think we have to start at the beginning.

    What I need from you are:
    a. the contents of a few cells in the Worksheet (2 or 3 each from Column A & B) including large numbers you are having problems with.
    b. What you expect the results to be.
    c. Exactly how you are using Notepad.
    d. A description of what you are trying to accomplish.

    -------------
    There are probably several ways we can solve your problem which include:
    a. The current method using NotePad and SendKeys.
    b. Similar to the current method, with a slightly more advanced NotePad interface.
    c. Similar to the current method, but using Microsoft Word instead of NotePad.
    d. Writing the output directly to a text file from the Excel Macro.
    e. Writing the output to a separate sheet in the Excel file, then copying the contents of the sheet to a text file.

    The method used depends on what you want. The current method is probably the least reliable, but if it's what you want, it is what you will get.

    Lewis

  24. #24
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    Re: If< 0 problem

    I solved it thanks for the help

+ 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. Replies: 6
    Last Post: 10-20-2013, 07:16 PM
  2. input box problem, cell filtering problem, result display while locking sheet
    By croozin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-01-2013, 08:52 AM
  3. Replies: 6
    Last Post: 05-28-2013, 05:08 PM
  4. Replies: 2
    Last Post: 01-22-2013, 07:09 AM
  5. Problem using formulas within macro + problem with defined name.
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-11-2011, 04:39 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