title: Remove extra spaces from cells in column
body: <p>I wrote the following code to do inventory scanning bar-codes but for some reason when I scan the bar-code it is adding extra spaces in the cells and the result are not showing up as expected.</p>
  
  <p>How  do I remove the extra spaces from the cells in column?</p>
  
  <pre><code>Option Explicit
  Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
  
      If Target.Cells.Count &gt; 1 Or IsEmpty(Target) Or Target.Column &lt;&gt; 1 Then Exit Sub
  
      If Not SheetExists("WarehouseInventory") Then Exit Sub
  
      Dim result As Variant
  
      Set result = Sheets("WarehouseInventory").Cells.Range("E:E").Find(Target)
  
      If result Is Nothing Then
         Target.Worksheet.Cells(Target.Row, 2) = "Data Maybe Bin #?"
      Else
          Target.Worksheet.Cells(Target.Row, 2) = result.Worksheet.Cells(result.Row, 4)
          Target.Worksheet.Cells(Target.Row, 3) = result.Worksheet.Cells(result.Row, 5)
          Target.Worksheet.Cells(Target.Row, 4) = result.Worksheet.Cells(result.Row, 6)
          Target.Worksheet.Cells(Target.Row, 5) = result.Worksheet.Cells(result.Row, 7)
      End If
  
  End Sub
  
  Public Function SheetExists(SheetName As String) As Boolean
      Dim ws As Worksheet
      SheetExists = False
  
      For Each ws In ThisWorkbook.Worksheets
          If ws.Name = SheetName Then SheetExists = True
      Next ws
  
  End Function
  </code></pre>
  
  <p>Barcode will be scan on column A</p>
  
  <p><img src="https://i.stack.imgur.com/1lQZz.png" alt="enter image description here"></p>