+ Reply to Thread
Results 1 to 5 of 5

Excel Macro to print selection when cell value is entered - won't stop printing

  1. #1
    Registered User
    Join Date
    05-10-2022
    Location
    Lebanon, NH
    MS-Off Ver
    365
    Posts
    5

    Excel Macro to print selection when cell value is entered - won't stop printing

    Hi,

    I have two cells that I want to scan data into (A2 and B2), and once the last cell (B2) is entered, for the macro to print a selection automatically and then clear the two cells. I am using a scanner with a carriage return to enter the data. It prints and clears the data as intended (the first label) but then it won't stop printing labels with blank info. Any ideas on how to get it to stop printing? I thought the copies:=1 would take care of this, but it doesn't. Below is my current code.
    Please Login or Register  to view this content.
    Thanks in advance!
    Last edited by davesexcel; 05-10-2022 at 09:44 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    10-12-2021
    Location
    CT
    MS-Off Ver
    365
    Posts
    462

    Re: Excel Macro to print selection when cell value is entered - won't stop printing

    lol you have it set up so if the range is changed it will fire your code... your code is firing the code over and over again because the code changes the range.

  3. #3
    Valued Forum Contributor
    Join Date
    10-12-2021
    Location
    CT
    MS-Off Ver
    365
    Posts
    462

    Re: Excel Macro to print selection when cell value is entered - won't stop printing

    This will fix your issue:

    Please Login or Register  to view this content.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: Excel Macro to print selection when cell value is entered - won't stop printing

    When you clear contents, you are activating the worksheet_change event again, so you end up in an infinite loop.

    replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-10-2022
    Location
    Lebanon, NH
    MS-Off Ver
    365
    Posts
    5

    Re: Excel Macro to print selection when cell value is entered - won't stop printing

    That worked, thank you both!

+ 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 to stop the printer from printing if a cell is blank
    By taflorida in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-07-2019, 03:02 PM
  2. Replies: 7
    Last Post: 12-08-2016, 12:25 PM
  3. Replies: 3
    Last Post: 10-24-2013, 02:28 PM
  4. excel 2010 crashes when printing and print.preview Macro
    By zmhnk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-08-2012, 09:24 AM
  5. Date, Cell Selection and Print Macro - Possible?
    By EinGutesBier in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-03-2008, 12:55 PM
  6. Printing Macro-How can I make my print macro force excel
    By chris_mayer in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-20-2006, 09:26 PM
  7. [SOLVED] When I copy a cell in Excel it will print how do i stop this
    By Excel Man in forum Excel General
    Replies: 0
    Last Post: 09-19-2005, 03:05 PM

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