I assume that you have a "keyboard wedge" type bar code scanner.
If this is the case then you have only a few options.
Bar codes can only contain ASCII characters. The keyboard wedge part
of your bar code scanner basically translates the characters that are
encoded in the bar codes that you read with it to equivalent
keystrokes that get sent in the keyboard port on your PC.
This means that you cannot encode "keystrokes" directly in the bar
code unless your bar code scanner provides some way to translate
specific ASCII characters to specific keystrokes. You will need to
read the users manual for your bar code scanner to see if this is
possible. If it is possible then you could encode non printable ASCII
characters into your bar code and then map these characters to
appropriate cursor navigation keystrokes in the bar code scanner.
Fortunately most bar code scanners automatically translate ASCII 13
characters to "Enter" keystrokes and they also usually translate ASCII
9 characters to "TAB" keystrokes. The Enter key in Excel will usually
move the cursor down one cell and the tab key will move the cursor to
the right one cell. If this is all you need then try encoding a single
carriage return character (ASCII 13) or a single Tab character (ASCII
9) in a bar code. When you want to move the cursor down, scan the
carriage return bar code. When you want to move the cursor one cell to
the right, scan the Tab bar code.
If you have a bar code scanner that has a RS232 output then you have
another more elegant option. In this situation, you could use a
software product called WinWedge from TAL Technologies to read the
data from the bar code scanner and feed it directly to a VBA
subroutine in Excel where you could interpret the data that you scan
in any way that you want. For example, you could make up your own
"command language" and encode commands directly in your bar codes.
When you scan a bar code, WinWedge would force Excel to run a VBA
subroutine that could then request the data from WinWedge and pull it
into a string variable. You could then use VBA code to examine the
data that came in from the bar code scanner and it it is one of your
commands, you could perform whatever cursor navigation operation is
associated with the command.
One big advantage of the RS232 scanner and WinWedge is that you can
minimize Excel and WinWedge and be able to collect data to the
spreadsheet in the background and not have to worry about where the
cursor is in Excel.
For more information about WinWedge, please visit:
http://www.taltech.com/products/winwedge.html
For information about bar code scanners that have RS232 output visit:
http://www.taltech.com/products/bc_reader.html
If you use a RS232 scanner then your PC must be equipped with at least
one COM port.