Barcode Scanner --> 2 Columns

Route246

New Member
Joined
Oct 16, 2006
Messages
2
I have a handheld barcode scanner that acts just like a keyboard. It enters a string from a barcode and then sends an "enter" string at each barcode scanned.

I want to populate pairs of scanned strings into A and B columns, sequentially through rows 1, 2, 3, etc.

1st scan --> A1
2nd scan --> B1
3rd scan --> A2
4th scan --> B2
5th scan --> A3
6th scan --> B3

and so on.

I can do this in UNIX using PERL, bash, awk, etc. but have not figured out how to do it easily using Windows, in particular Excel. I have installed cygwin on Windows and achieve the goal but I would rather do it in a more "native" Windows app like Excel if possible.

I am a UNIX admin and know very little about Excel. I don't think this is a difficult task for somone fluent in Excel and VBA.

Thank you.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

tmcfadden

Board Regular
Joined
Aug 17, 2005
Messages
151
Here's a pretty crude way to accomplish this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Static nCount As Integer

If (nCount = 0) Then nCount = 1

If (nCount Mod 2) Then
    Range(Target.Offset(0, 1).Address).Select
    nCount = nCount + 1
Else
    Range(Target.Offset(1, -1).Address).Select
    nCount = nCount + 1
End If
End Sub

The issue here is that you don't want to leave this code in as it will always affect this worksheet. You might want to put it in but comment it out when you don't need it.

Also, if you need to reset 'nCount' you'll have to use the immediate window to enter "nCount = 0" ( or "nCount = 1" really ).

While this code is uncommented, it will select the appropriate cell based on whether it is the first or second entry.

-Tim
 

Route246

New Member
Joined
Oct 16, 2006
Messages
2
Great. This works perfectly fine. I just wanted something quick and dirty to get ordered pairs of tokens aligned in Excel and this does it fine.

Thank you very much.
 

Forum statistics

Threads
1,136,621
Messages
5,676,852
Members
419,656
Latest member
lironprofit

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top