+ Reply to Thread
Results 1 to 11 of 11

Printing Results to a text file

  1. #1
    Registered User
    Join Date
    05-09-2010
    Location
    england
    MS-Off Ver
    Excel 2003
    Posts
    8

    Printing Results to a text file

    Hi, I'm having a little trouble with this code below, the code works perfectly fine but stops when it finds an empty row. I intentionally include 1 blank row between groups of rows on the spreadsheet i'm working on. This cause's this code to stop after one group, i've tried telling the code to check the first empty row with the next row coming up to see if that row is empty also but my attempts failed & i'm not sure how to do it.
    I have included the code below.

    Can this code be made to only stop once it finds 2 empty rows and not just 1?

    Below working code if no blank rows are present.
    Please Login or Register  to view this content.
    below code that i tried editing to check for 2 rows.

    Please Login or Register  to view this content.
    Thanks

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Printing Results to a text file

    Hello chuckie2010,

    If you have only one blank between the groups you could find the end of the range using something like this...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    05-09-2010
    Location
    england
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Printing Results to a text file

    Hi Leith, just tried that code in my spread sheet and it just produces an empty file. I've attached a copy of my excel sheet, and a copy of the exported results that my first lot of code created.

    Hopefully you can help elimate the problem.
    Attached Files Attached Files

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Printing Results to a text file

    Hello chuckie2010,

    My typing is my weakness. I corrected the type in the macro. Here is the working code. This has been added to the attached worksheet.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    05-09-2010
    Location
    england
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Printing Results to a text file

    Hi Leith,
    Your a star, thanks for fixing that code.
    This evening i've been working on another macro for the same spreadsheet which is based on the same code. Would you mind performing your magic on this please.

    Please Login or Register  to view this content.
    Thanks Leith

    James

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Printing Results to a text file

    Hello James,

    I can help you but I am not sure what is you want help with. Can you provide me with some more detail and a before and after example of the file layout?

  7. #7
    Registered User
    Join Date
    05-09-2010
    Location
    england
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Printing Results to a text file

    Hi Leith, I've been playing with this code again this evening and progressed a little further with my existing code and implementing your code a little further with the range feature.

    The code below works on one ranged column but can this be upped to 3 ranged columns?
    I've tried to include as many comments as possible in the code aswell.

    Please Login or Register  to view this content.
    From how i understand the code, it sets the range on column BA and looks at each row in that column for the letter 'm'

    can i adjust the code to look at 3 coloumns and only if the row matches the 3 column criteria is exported to the file i'm creating.


    Cheers

    James

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Printing Results to a text file

    Hello James,

    Yes, the macro can be changed to export the row only if all three conditions are met. Can you explain this condition?

    ' column W to be empty, if anything is in the column the to leave it out.

  9. #9
    Registered User
    Join Date
    05-09-2010
    Location
    england
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Printing Results to a text file

    On my spreadsheet i have the words No Image if i haven't photographed the item yet.

    If there are no words in the column w, on that particular row it can be included in the export, because description, image and everything else are correct. If no image exists then that cell will include the words "No Image" and the row cant be included in the export.

    hope that makes sense.

    ta

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Printing Results to a text file

    Hello chuckie2010,

    I changed the macro to check the three cells on each row before exporting the data. Here is the revised macro. This has been added to the attached workbook.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    05-09-2010
    Location
    england
    MS-Off Ver
    Excel 2003
    Posts
    8

    [SOLVED] Re: Printing Results to a text file

    Thanks its working how i would like it to.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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