+ Reply to Thread
Results 1 to 10 of 10

Print specific rows/columns IF a cell meets criteria

  1. #1
    Registered User
    Join Date
    10-09-2012
    Location
    New York, N
    MS-Off Ver
    Excel 2003
    Posts
    14

    Print specific rows/columns IF a cell meets criteria

    Hello,

    I have spent the last 45 minutes going through different threads that came up in a search for printing marcos and my head is spinning so I thought I would just ask instead.

    I would like to have a macro that will print columns A through I IF column B says REVCO. This would need to print to a network printer that is not the default printer on the computer so if that matters, the address of the printer is \\SMSKPPRT23\p1275_lab_c326a_1

    I am trying to upload the file but it isnt working so I will keep trying but if there is a code in the meantime, that would be awesome.

  2. #2
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: Print specific rows/columns IF a cell meets criteria

    Need to know where in column "B" Revco Occurs, but this assumes it occurs in "B1", and your data extends down column "A":


    Please Login or Register  to view this content.
    Then, we will tie in the following to send the document to the printer:

    Please Login or Register  to view this content.
    So im assuming we need the network printer name
    Last edited by jayinthe813; 10-15-2012 at 01:14 PM.

  3. #3
    Registered User
    Join Date
    08-15-2012
    Location
    Las Vegas
    MS-Off Ver
    Excel 2010
    Posts
    87

    Re: Print specific rows/columns IF a cell meets criteria

    After the area to print has been set, why not just bring up the Print dialog and let the user pick?

    Please Login or Register  to view this content.
    I like this approach since the other way hard codes a printer. If you ever want to print to a different printer you have to go in and modify the code.

  4. #4
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: Print specific rows/columns IF a cell meets criteria

    Yeah, but he sounded like he wanted to more automate the entire process completely, but you are correct, it is a big assumption and if that printer changes, or changes are needed, code will need to be modified...

  5. #5
    Registered User
    Join Date
    10-09-2012
    Location
    New York, N
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Print specific rows/columns IF a cell meets criteria

    Thank you both so much. What I need is for the macro to look for REVCO in ANY of the cells in column B (not just B1) and then I only want it to print columns A-I in those rows that have REVCO.

  6. #6
    Registered User
    Join Date
    10-09-2012
    Location
    New York, N
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Print specific rows/columns IF a cell meets criteria

    Oh and thanks for the printer code for brining up the dialog box - that is super helpful.

  7. #7
    Registered User
    Join Date
    10-09-2012
    Location
    New York, N
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Print specific rows/columns IF a cell meets criteria

    I put in this code:

    Please Login or Register  to view this content.
    And it works, however it still prints rows that do not say REVCO in column B....Do I need to set a filter?

  8. #8
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: Print specific rows/columns IF a cell meets criteria

    you will need to do this:

    Please Login or Register  to view this content.
    what is the name of the printer and we can automate it or replace what i highlighted in bold with g8r777's solution:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    10-09-2012
    Location
    New York, N
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Print specific rows/columns IF a cell meets criteria

    Thank you so much. When I ran the macro, it gave me a type mismatch error for this row:

    Please Login or Register  to view this content.
    Also, it wants to print each row on a separate page. Is it possible to print them all on one page? Also, is it possible to have row A print at the top? It is a header row....
    Inventory Test 4.xlsm

    FINALLY got the file attached!
    Last edited by tiannaleft; 10-15-2012 at 04:01 PM.

  10. #10
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: Print specific rows/columns IF a cell meets criteria

    Try this:

    Please Login or Register  to view this content.
    Please note, in the example you provided, the first "REVCO" was entered in as " REVCO", you will need to make sure you data enter cells correctly in order for this to work, or you will need to introduce * as wildcard, OR if beginning spaces are a problem, you will need to go to Data tab > Text To Columns > Fixed Width and press finish
    Last edited by jayinthe813; 10-16-2012 at 08:59 AM.

+ 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