I have a barcode scanner. So when the barcode is scanned using a gun, the value normally is entered to textfield placed on the screen.

So I have made an excel macro. And when the barcode is scanned, the text appears on the cell ending with the new line character (text+"\r\n" is provided by the scanner itself). So an event is triggered and does the rest.

The problem is that the event is only triggered with a new line character. What if the barcode scanner didn't provide \r\n after every barcode output. How do I deal with such situations? How do I detect it and trigger event?

5 Years
Discussion Span
Last Post by adam_k

I'm not sure how you can trigger an event with the CRLF. My guess is that you are using the Worksheet_Change event and in that you verify if the newly entered text ends with \r\n. If this is the case you could remove this test - BUT be warned that this will cause your trigger to fire with every change, including when your macro does stuff like clear the value from the worksheet, causing an infinite loop.

Can you share details on what you are doing with this macro - and possibly the macro itself? Perhaps there is an alternative.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.