+ Reply to Thread
Results 1 to 6 of 6

VBA to split data to worksheet/workbook , delete zero values, set print area

  1. #1
    Forum Contributor
    Join Date
    01-26-2016
    Location
    TX
    MS-Off Ver
    Excel 2016
    Posts
    100

    VBA to split data to worksheet/workbook , delete zero values, set print area

    I have a macro that currently works for me (after much help from others on another thread) but I would like some help tweaking it.
    Please note that the subtotal function excludes the first sheet because doing so isn't necessary and will cause excel to crash due to #of rows.



    1. On Sheet 1, how can I delete any rows that have zero value on Column K?

    2. The data is split into worksheets by column A (Invoice #) but it isn't done in alphabetical order, even if the first sheet is in alphabetical order. How can I change that?

    3. How can I save each tab as a separate Excel 2013 file without deleting it in the original sheet?

    4. I have a print area set that includes all columns but I would like to auto detect how many pages are needed. The limit of rows I would like to have in one page is 75. For ex, an invoice with 230+ rows would require 4 sheets.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VBA to split data to worksheet/workbook , delete zero values, set print area

    I think I can help with # 1. Add the following code into your existing code to delete rows that contain 0
    Please Login or Register  to view this content.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    423

    Re: VBA to split data to worksheet/workbook , delete zero values, set print area

    This should help with questions 1 and 3:
    Please Login or Register  to view this content.
    Unrelated to you questions, let me suggest you avoid using 'Select' - it is almost never needed, and it really slows things down. As an example, you can replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    01-26-2016
    Location
    TX
    MS-Off Ver
    Excel 2016
    Posts
    100

    Re: VBA to split data to worksheet/workbook , delete zero values, set print area

    gmr4evr1 - Thank you for that code, it worked! this solved request #1.

    mgs73 - that didn't seem to work. As far as the alphabetical order of the sheets being saved, I realized it's because of the sorting that I have, I only intended it to do so on the sheets that are created. I'm attempting to include this after the Next ws portion but I'm getting an error (Compile Error: Next without For). Please see below. How can I properly move the highlighted yellow code?


    Please Login or Register  to view this content.

  5. #5
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VBA to split data to worksheet/workbook , delete zero values, set print area

    I'm glad that my post worked for you.
    I think your Next without For error might have to do with the Next ws. You have to have a For in order to use Next. in this case, I think you need a For ws = .......

  6. #6
    Forum Contributor
    Join Date
    01-26-2016
    Location
    TX
    MS-Off Ver
    Excel 2016
    Posts
    100

    Re: VBA to split data to worksheet/workbook , delete zero values, set print area

    gmr4evr1 - that didn't work but it's possible I did this incorrectly. Would you mind sharing your suggestion within the coding I previously provided?

    Thanks in advance.

+ 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. Macro - Set Print Area for Changing Data Area
    By ksp in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-27-2013, 04:19 AM
  2. delete everything but print area
    By bodhi2.71828@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-19-2013, 02:26 PM
  3. Replies: 1
    Last Post: 02-12-2013, 12:16 PM
  4. Split raw data into several worksheet and save as new workbook filter by column name
    By dare2join in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2012, 11:15 AM
  5. VBA. identify unique values, loop them, filter them in, set print area & print it
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-09-2012, 09:56 PM
  6. Split cells without changing overall width of print area?
    By Kenny Bones in forum Excel General
    Replies: 2
    Last Post: 09-27-2011, 04:34 AM
  7. Split Workbook with Many Sheets into a file for each Worksheet and delete all others
    By Please_Help in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-19-2010, 07:31 PM
  8. Replies: 8
    Last Post: 05-23-2007, 06: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