title: How to increase only last digit of a serial number string in Excel VBA?
body: <p>I'm new to vba and trying to write a barcode scanner algorithm. It works fine right now but I want to keep serial numbers in my exel table and their structure has to be like "A151000". I want with each barcode entered a cell with an inputbox also be assigned to a serial number. for example when a new entry(Barcode) written in column C I want in column B serial numbers last digit increased by 1 and stored in that cell automatically.
  Right now I can drag the cell from corner and exel increases the last digit. How can I trigger this with new entries automatically? Thanks in advance.</p>
  
  <pre><code>A151000  
  A151001  
  A151002  
  ...
  </code></pre>
  
  <p><br></p>
  
  <pre><code>Sub DataInput()
  
  Dim SearchTarget As String
  Dim myRow As Long
  Dim Rng As Range
  
  
  Static PrevCell As Range
  Dim FoundCell As Range
  Dim CurCell As Range
  Dim a As String
  Dim Target As Range
  Dim buttonclick As Boolean
  V = True
  
  If PrevCell Is Nothing Then
      myRow = Selection.Row
      Set PrevCell = Range("C" &amp; myRow)
  End If
  
  Set Rng = Range("C:C,C:C") 'Columns for search defined here
  
  With Rng
      Set FoundCell = .Cells.Find(What:=SearchTarget, _
          After:=PrevCell, LookIn:=xlFormulas, LookAt:= _
          xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
          MatchCase:=True)
  End With
  
  Dim Eingabezahl As String
  
  Do While Eingabezahl! = ""
      Eingabezahl = InputBox("Last barcode scanned" &amp; "  " &amp; Eingabezahl)
      Range("C" &amp; Range("C" &amp; Rows.Count).End(xlUp).Row + 1) = Eingabezahl
      Range("D" &amp; Range("D" &amp; Rows.Count).End(xlUp).Row + 1) = Now()
      Range("E" &amp; Range("E" &amp; Rows.Count).End(xlUp).Row + 1) = "VALID"
  Loop 
  
  End Sub
  </code></pre>