+ Reply to Thread
Results 1 to 7 of 7

Save file in some kind of pattern

  1. #1
    Registered User
    Join Date
    01-20-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    79

    Save file in some kind of pattern

    Hi, I have an excel file. One of column has such a pattern:
    Please Login or Register  to view this content.
    What I want is to save the file as two files. One contains all rows having odd numbers such as B01,B03,..D01 etc. The other one contains all rows having even numbers such as B02, B04, D02 etc.

    Do I need to write code or just use some kind of trick?
    Thanks for help.
    Last edited by zhshqzyc; 02-24-2011 at 01:26 PM. Reason: typo

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,945

    Re: Save file in some kind of pattern

    You have given a short example, but what is the pattern? I actually don't see a pattern, except that each row is built from a letter followed by 0 followed by digit, where letters are strictly non-ascending and digits within that letter are strictly non-ascending.

    Are there really dots or does that mean a blank row, or something else?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    01-20-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    79

    Re: Save file in some kind of pattern

    The pattern is up to the last digit which can be odd oe even. Letters are not matter with the issue.
    .. doesn't mean blank rather than etc. because there are hundreds of rows.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,945

    Re: Save file in some kind of pattern

    I started to try and figure out how to do this with formulas but I decided it would be easiest to just write the code, which took me about 10 minutes to write and test. This code runs in the worksheet with the data. It creates two files, odd.xlsx and even.xlsx. You get an error message pop up if the string does not end in a digit. This makes no assumptions at all about the format of the data, just that it is all in column A and it stops when it encounters a blank line.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-20-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    79

    Re: Save file in some kind of pattern

    I still have two questions. The first one is the code only save one column but I want to save the entire row. For example, once "B01" occuried, it wil save to wbOdd.xlsx.
    Please Login or Register  to view this content.
    Question 2:
    The range starts from the second row. The first row is a header. I want to write the header to each file not by hand. How to do it?

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,945

    Re: Save file in some kind of pattern

    Quote Originally Posted by zhshqzyc View Post
    I still have two questions. The first one is the code only save one column but I want to save the entire row.
    Your initial example did not mention that there was any other data.

    The range starts from the second row. The first row is a header. I want to write the header to each file not by hand. How to do it?
    Your initial example did not mention this, either.

    I think this modification will cover those two issues. Based on your sample data above it appears that the key is in column I.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-20-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    79

    Re: Save file in some kind of pattern

    Perfect. Thanks.

+ 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