• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA Append ActiveCell value to text file

Nu2Java

Member
Hi All,

I have a column that is populated from scanning barcodes. After each barcode is scanned, the text is entered into the cell and moving down one cell. How can I get that value so I can append it to a text file? The scanned items are not always in numerical order by row, which is why I need to get the value of the cell that was just scanned and send that to the text file.
 
I take it you don't want a manual process; you want Excel to see the incoming value and write it out automatically, without you having to do anything extra?

I mean, normally I'd picture you reading a lot of bar codes, and then at the end of the session exporting all the new data to wherever. Or (still at the end of the session) running a VBA program that would write it all out. But it sounds like you want Excel to run this process every time the new value comes it?

If so, I guess you want the Worksheet_Change event. If you write a program that uses that event, and assuming EnableEvents is turned on, then every time you change a value in a cell in that worksheet, the program would run automatically; Excel would provide a variable that points to the cell(s) that changed. Your program would have to a) look at the row and column of the changed cell to be sure it's in the range you're concerned with; if it's not in the right column, for instance, your program would see that and Exit. But if the change passes that test, and any others you think of, then it can write out the value.
 
Thanks for this detailed explanation BobBridges, much appreciated. At the moment, I am wanting to do this just one cell at a time only for the reason that if a person stops in the middle, then I can't tell what range to append when they come back to scanning the barcodes. Right now I am using the worksheet_change event and getting the target.value and sending that to the text file. I think it will be a 'work in progress' for a week or so until I see how many issues this presents.
 
Back
Top