+ Reply to Thread
Results 1 to 18 of 18

Loop writing blank cells

  1. #1
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Loop writing blank cells

    Something in the For = A loop is preventing all the cells from being rewritten correctly.

    For some reason cell AF4 is the first cell of many not to be written over to the new sheet.
    Excel.JPG

    That cell should have written a converted value in the new sheet cell D2.
    Excel.JPG

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

  2. #2
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Loop writing blank cells

    There is nothing immediately obvious. Unable to run the code because of various missing values. But you may be able to sort it with a bit of detective work

    immediately below line
    Please Login or Register  to view this content.
    insert the line
    Please Login or Register  to view this content.
    That will tell you which cell address and value is being used for cell D2
    If (as I suspect) it is not being updated, then one of your conditions has an error

  3. #3
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Loop writing blank cells

    It is as you suspect, one of the conditions in the loop must not be working because it is not being updated. Hmmmm

  4. #4
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Loop writing blank cells

    Move the message box line back up the code - put it above the if.... and test all the values - if all ok move it up again to the previous if ....

    cell AF4 = column32, row 4
    So A must be 4 and B 32
    so
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Loop writing blank cells

    Are you able to run the code in this full excel file with macros? I keep stepping through watching the locals window and I don't understand why it isn't working.
    When you click on the button in the Start sheet you only need to click on the "Get Upchain File" button and direct it to this attached .csv then click the "Process Data" button to run the macro in reference.
    Attached Files Attached Files
    Last edited by cnash52; 03-03-2016 at 03:39 PM.

  6. #6
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Loop writing blank cells

    The downchain file is example.csv
    Which is upchainfile file?

    In which file is the code that appears in post#01?

  7. #7
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Loop writing blank cells

    The downchain file isn't setup in the macro yet. The attached csv is the same as the pic in post 1 and is for the upchain file, you an use it for both get buttons. I had to remove lines so it was small enough to upload. After you run the process macro by clicking the Process button it populates sheet "Upchain Edit" which is where the second image comes from.

  8. #8
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Loop writing blank cells

    ok. Will have a go at this tomorrow

  9. #9
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Loop writing blank cells

    Thank you very much for your help. This loop has stumped me all day and I need to get it to work to move on with the project. It is so frustrating because it makes logical sense to me but it is just skipping cells for some unknown reason.

  10. #10
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Loop writing blank cells

    I have started looking at this for you.
    The macro does now run.I am now creating various table dumps to try to establish where AF4 is falling down a hole!

  11. #11
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Loop writing blank cells

    I have tried everything I can think of and everything that has been suggested and nothing has worked. You have no idea how grateful I will be to get past this coding hurdle.

  12. #12
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Loop writing blank cells

    I am guessing that you will have your mouth open in surprise when you read this. The answer is from "left field" to say the least.
    After a lot of checks I learned that the test was failing for AF4 because -1.9 does not equal -1.9
    I have no explanation (yet) but when I narrowed it down and only allowed cell AF4 to go through the macro mincer, that is what VBA told me! When I took one number away from the other, VBA refused to do the maths and reported an incompatibility.
    My solution (believe it or not) is to multiply BOTH sides of your condition by 10 and then by magic -19 equals -19.
    (I guess any number would do)

    I have modified the code slightly (personal preference), and got rid of some unnecessary brackets.

    So replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    run the code and report back!

  13. #13
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Loop writing blank cells

    Now it is pulling different cells as blank. IE not populating C2 anymore. I am still trying to figure this out. Maybe I need to try to write the loop differently or maybe some sort of excel cell formatting or dim issue.
    Excel.JPG

  14. #14
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Loop writing blank cells

    !!!!!Bump!!!!!

  15. #15
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Loop writing blank cells

    Apologies for ignoring you without realising it.
    For some reason, a few days ago something happened to my "subscribed threads" - everything appeared to have been dealt with they lost the usual "bold"

    I will remind myself of where we were up to, and get back to you later today.
    Kevin
    Last edited by Kevin#; 03-09-2016 at 11:27 AM.

  16. #16
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Loop writing blank cells

    Ok - I have re-familiarised myself with your thread.
    When I amended your code (as per post#12) I assumed (because the cell that you mentioned as being in error had been populated) that all was therefore sorted. Clearly there must be another issue elsewhere in the code. Probably another mismatch error.
    I wonder if the cells that are blank now were populated before, and the ones that are populated now were not populated before (do you know if this is the case?).

    In order that I can be satisfied that all issues are resolved before I reply again, can you attach a workbook (not a picture) showing what values should be in all those empty cells after the macro has run (ie fill in all the blanks)

    thanks

  17. #17
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Loop writing blank cells

    I have found the error!! It still doesn't make sense but when you remove the convert function or just have it go from "m" to "m" then the entire row is populated correctly. Thank you for your help and willingness to continue to struggle though this with me. The error was in the convert function the whole time.

  18. #18
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Loop writing blank cells

    Well done. I will try to look at that sometime - need to learn and understand these things.

+ 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] loop to copy blank cells between 2 filled cells
    By Spyderwoman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2016, 12:44 AM
  2. [SOLVED] Copy Cells to available blank cells in rows below loop
    By lee1000d in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-17-2015, 02:21 PM
  3. [SOLVED] Skip blank cells in a loop
    By k64 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-14-2013, 02:29 PM
  4. [SOLVED] Help fix my loop to fill in blank cells down a row
    By mellowmarshall in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-14-2013, 01:29 PM
  5. [SOLVED] Find first non-blank cell after a group of blanks copy offset cells, find next blank, loop
    By gwsampso in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-21-2012, 06:11 AM
  6. Loop through a range pasting in Blank Cells
    By luv2bowl2004 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-29-2011, 01:20 PM
  7. how do I skip blank cells when writing formulas
    By KatB in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-11-2006, 05:00 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