automated cursor movement in Excel

K

KelvinP

Hello, I want to enter data from a bar code scanner into a spreadsheet. I
want to start entering data in cell B2, the next entry into C2, then D2.
Following the third entry I want to move down to the next row and enter data
in the same manner, B3, C3, D3, then B4, C4, D4, etc. I've tried using Target.
Offset. It works to change columns after a specified entry, but I can't seem
to get the correct VB syntax to change the active cell to the next row when
working across columns. Seems like it should be pretty simple, but I am all
thumbs when it comes to programming.
 
J

JLGWhiz

Lets say you have 1000 records.

Sub barCode()
Dim RowCount As Long
RowCount = Round(1000/3) + 1
For i = 1 To RowCount
For j = 1 To 3
If IsEmpty(Cells(i, j)) Then
'enter the code for barcode
Else
MsgBox "Cells contain data, TERMINATE!"
Exit Sub
End If
Next j
Next i
End Sub

This should give you an idea of how to walk down the
rows three column at a whack.
 
J

JLGWhiz

To see the macro operate, substitute this line:

'enter the code for barcode

With these two lines:

Cells(i, j) = x + 1
x = x + 1
 
O

Otto Moehrbach

First setup Excel to move one cell to the right when entering data. You do
this by clicking on Tools - Options - Edit tab. Check (click) "Move
selection after enter:" and select "Right".
Then right-click the sheet tab of your sheet and select View Code. Paste
the following macro into that module. "X" out of the module to return to
your sheet. This macro will select the cell in Column B one row down when
anything is entered into any cell in Column D. HTH Otto
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("D:D")) Is Nothing Then
Target.Offset(1, -2).Select
End If
End Sub
 
F

Frank Warnars

Hi,

I saw your message regarding moving to the next row
when barcode scanning. I haven't been able to figure this out, have you? If yes, can you share the solution?? I need to transfer about 10.000 cases
and need to upload these through an excel file.

Your help will be highly appreciated!

Many thanks!

Frank Warnars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top