sumsaam
Board Regular
- Joined
- Dec 31, 2012
- Messages
- 82
- Office Version
- 2010
- Platform
- Windows
Hi,
I got this code by searching on internet, and i use to count my store inventory by scanning there barcodes, We scan Barcodes in H1 cell, it searches that if barcodes list i pasted having the scanned barcode it increases the quantity of that item, if we scan a new barcode(not in pasted barcode list), it puts it at end of my list.
I facing a problem, mostly during counting i have to scan 10 or 20 pcs of same barcode is very time taking,
I want that a check box in excel sheet labeled "quantity mode". if i check the box "quantity mode" it should appear a box prompting for quantity after scanning a barcode, and if i uncheck the box it should take one scan as one pcs automatically.
the code i here
Private Sub Worksheet_Change(ByVal Target As Range)
Const SCAN_CELL As String = "H1"
Const RANGE_BC As String = "A2:A5000"
Dim val, f As Range, rngCodes As Range
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range(SCAN_CELL)) Is Nothing Then Exit Sub
val = Trim(Target.Value)
If Len(val) = 0 Then Exit Sub
Set rngCodes = Me.Range(RANGE_BC)
Set f = rngCodes.Find(val, , xlValues, xlWhole)
If Not f Is Nothing Then
With f.Offset(0, 2)
.Value = .Value + 1
End With
Else
Set f = rngCodes.Cells(rngCodes.Cells.Count).End(xlUp).Offset(1, 0)
f.Value = val
f.Offset(0, 1).Value = "enter description"
f.Offset(0, 2).Value = 1
End If
Application.EnableEvents = False
Target.Value = ""
Application.EnableEvents = True
Target.Select
End Sub
I got this code by searching on internet, and i use to count my store inventory by scanning there barcodes, We scan Barcodes in H1 cell, it searches that if barcodes list i pasted having the scanned barcode it increases the quantity of that item, if we scan a new barcode(not in pasted barcode list), it puts it at end of my list.
I facing a problem, mostly during counting i have to scan 10 or 20 pcs of same barcode is very time taking,
I want that a check box in excel sheet labeled "quantity mode". if i check the box "quantity mode" it should appear a box prompting for quantity after scanning a barcode, and if i uncheck the box it should take one scan as one pcs automatically.
the code i here
Private Sub Worksheet_Change(ByVal Target As Range)
Const SCAN_CELL As String = "H1"
Const RANGE_BC As String = "A2:A5000"
Dim val, f As Range, rngCodes As Range
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range(SCAN_CELL)) Is Nothing Then Exit Sub
val = Trim(Target.Value)
If Len(val) = 0 Then Exit Sub
Set rngCodes = Me.Range(RANGE_BC)
Set f = rngCodes.Find(val, , xlValues, xlWhole)
If Not f Is Nothing Then
With f.Offset(0, 2)
.Value = .Value + 1
End With
Else
Set f = rngCodes.Cells(rngCodes.Cells.Count).End(xlUp).Offset(1, 0)
f.Value = val
f.Offset(0, 1).Value = "enter description"
f.Offset(0, 2).Value = 1
End If
Application.EnableEvents = False
Target.Value = ""
Application.EnableEvents = True
Target.Select
End Sub