+ Reply to Thread
Results 1 to 9 of 9

Code to print columns with active rows not working

  1. #1
    Registered User
    Join Date
    06-08-2009
    Location
    Annapolis, Maryland
    MS-Off Ver
    Excel 2007
    Posts
    85

    Code to print columns with active rows not working

    Hello again! I have a code that will print all active rows on a spreadsheet, however I'm looking for something that will print certain columns when selected. Example:

    Columns A - N contain data for seven departments.
    I want to print columns B - D and then column F for one department; B - D with column G for another, etc. In other words, columns B - D will always be included with each department's column when it's printed.

    Is there a way a button could be placed over each department's column (say, columns G thru M) that will allow that to happen...and keep my macro to print only active rows? If so, please point me in the right direction; my searches have produced dead ends. Thanks!!
    Last edited by debbiesh; 07-09-2009 at 08:09 AM.

  2. #2
    Registered User
    Join Date
    06-08-2009
    Location
    Annapolis, Maryland
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Code to print columns with active rows not working

    Attached is a sample of what I have so far. A macro within each PRINT button is supposed to sort the column to contain "Non-Blank" rows and then print it. Three problems:

    1) I must not have the right code to sort within each column because, well, it doesn't.
    2) The code only wants to print down to the cell in row 8 rather than to the last active cell.
    3) Once it's printed, the code doesn't unhide the rows.

    Please help?
    Attached Files Attached Files
    Last edited by debbiesh; 07-09-2009 at 08:10 AM.

  3. #3
    Registered User
    Join Date
    06-08-2009
    Location
    Annapolis, Maryland
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Code to print columns with active rows not working

    Here's the code I have for each column. This is for column H, Routing --

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-08-2009
    Location
    Annapolis, Maryland
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Code to print columns with active rows not working

    I figured out what was wrong with my code. So this works to where I can now click the button and the correct columns will do their thing -- autofilter to show non-blank cells, show print preview, then show all again.

    Please Login or Register  to view this content.
    The only thing I can't do now is print down to the last active cell. I must've lost that code while messing with the rest of it.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Code to print columns with active rows not working

    Reset the print area to the whole sheet, Debbie.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    06-08-2009
    Location
    Annapolis, Maryland
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Code to print columns with active rows not working

    Thanks for replying shg!

    I don't know what happened but the code above now wants to include Columns A - C in the print preview, rather than B - C.

    Also, it wants to print rows 4, 5, 7, and 10 no matter what active cells are in the column to be printed. *sigh*

    Would it have to do with resetting the print for the whole sheet?

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Code to print columns with active rows not working

    Rewind a bit and explain what you want.

  8. #8
    Registered User
    Join Date
    06-08-2009
    Location
    Annapolis, Maryland
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Code to print columns with active rows not working

    You're right, it does sound a bit confusing. Lemme try again.

    I created six PRINT buttons, one for each column -- H, I, J, K, L, and M. I want the user to be able to click the button over one of those columns to print that particular column WITH columns B and C. I also want to only print the non-blank cells within that column.

    So I'm trying to create a code that will autofilter a column to include only non-blank cells, and then print columns B, C, and that chosen column, down to the last active cell.

    Make sense? Attached is another sample. I appreciate your help with this. I'm trying to make our production manager's job a little easier. :-)
    Attached Files Attached Files

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Code to print columns with active rows not working

    Debbie, try this:
    Please Login or Register  to view this content.
    Last edited by shg; 07-11-2009 at 05:20 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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