zoeken met scanner naar barcode in excel

Status
Niet open voor verdere reacties.

richie009

Nieuwe gebruiker
Lid geworden
7 mrt 2018
Berichten
3
Hallo allemaal,

Ben op zoek naar iemand die mij verder kan helpen met een vba sript. Mijn bedoeling is om met een barcode scanner in kolom B te zoeken naar een bestaande barcode en als hij deze gevonden heeft automatisch verder gaat naar naar kolom E om daar de aantallen in te vullen.

Onderstaand sript heb ik kunnen vinden maar heeft aanpassing nodig;

Private Sub CommandButton1_Click()
Dim code As Variant
Dim matchedCell As Range

code = InputBox("Please scan a barcode and hit enter if you need to")
Set matchedCell = Range("C2:C8").Find(what:=code, LookIn:=xlValues, lookat:=xlWhole, MatchCase:=True)
If Not matchedCell Is Nothing Then matchedCell.Offset(0, 2).Value = Now
End Sub




Ik heb verder geen kennis met vba daar mij vraag voor hulp

Alvast bedankt allemaal en ik ben erg benieuwd
Bekijk bijlage test zoeken.xls

Gr Richard
 
onderstaande code gebruik ik om te scannen.
er wordt gezocht in hoofdblad in kolom M

Code:
ub Scannen()
'
' Scannen Macro
'
    Dim FindString As String
    Dim rng As Range
    FindString = InputBox("Scan de Barcode", "Gemaakt door")
    
    If Columns("M").Hidden = True Then
    MsgBox ("U hebt Kolom M verborgen ")
    Exit Sub
    End If
        
    If Trim(FindString) <> "" Then
        With Sheets("Hoofdblad").Range("M:M")
            Set rng = .Find(What:=FindString, _
                            After:=.Cells(.Cells.Count), _
                            LookIn:=xlValues, _
                            LookAt:=xlWhole, _
                            SearchOrder:=xlByRows, _
                            SearchDirection:=xlNext, _
                            MatchCase:=False)
            If Not rng Is Nothing Then
             'On Error GoTo ErrHandler:
            'Application.Goto Rng.Offset(0, 4), True
            'If ActiveCell.Value <> "" Then
            'ActiveSheet.Unprotect
             'MsgBox "I'm not empty!"
            'ActiveCell.Locked = True
            'ActiveSheet.Protect

            'End If
'ErrHandler:
               ' Application.GoTo rng.Offset(0, 5), True
                'rng.Offset(0, 3).FormulaR1C1 = "JA"
            Else
                MsgBox "Lidnr niet gevonden", , "Welkom   " & Application.UserName
            End If
        End With
    End If
'
End Sub
 
Hallo Gober bedankt voor je snelle bericht, is het mogelijk dat jij deze code plaatst in de bijgevoegde sheet want ik krijg allemaal compileerfouten alvast bedankt.

Gr. Richard
 
Bedankt Gober voor je snelle reactie ik ben echt geholpen.

Thanks Richard
 
Iets anders uitgevoerd
Code:
Sub Scannen()
Dim FindString As String
    FindString = InputBox("Scan de Barcode", "Gemaakt door tester")
    
    If Sheets("Blad1").Columns(2).Hidden = True Then
        MsgBox "U hebt Kolom B verborgen"
    Exit Sub
    End If
        
    If WorksheetFunction.CountIf(Sheets("Blad1").Columns(2), FindString) = 0 Then
        MsgBox "Code niet gevonden", vbCritical, "Welkom   " & Application.UserName
    Exit Sub
    End If
    Application.Goto Sheets("Blad1").Range("B:B").Find(FindString, , , xlWhole).Offset(, 3), True
End Sub
 
Laatst bewerkt:
Getallen zoeken heeft de voorkeur met xlwhole.
Code:
Sub Scannen()
Dim c As Range, FindString As String
    FindString = InputBox("Scan de Barcode", "Gemaakt door tester")
    
    If Sheets("Blad1").Columns(2).Hidden Then
        MsgBox "U hebt Kolom B verborgen"
    Else
     Set c = Sheets("Blad1").Columns(2).Find(FindString, , , xlWhole)
       If Not c Is Nothing Then
         Application.Goto c.Offset(, 3), True
       Else
         MsgBox "Code niet gevonden", vbCritical, "Welkom   " & Application.UserName
       End If
  End If
End Sub
 
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan