tourless
Board Regular
- Joined
- Feb 8, 2007
- Messages
- 144
- Office Version
- 365
- Platform
- Windows
Hi Folks,
I can remove and/or replace first an last x number of characters from strings but have no idea how to cut it to the clipboard to be used as another string...
I'm scanning a barcode. The barcode reader appends tick symbols at the start and end of the barcode. I remove those, then remove the first few characters from the now numeric (no other symbols or text, just numbers), and before I remove the last two characters from the string I want to copy them to another cell, they are important in their own right. I've got most of it working so far but I'm stuck on the copy and paste of the last two characters. Here's what I'm working with so far... Any direction is always greatly appreciated.
I can remove and/or replace first an last x number of characters from strings but have no idea how to cut it to the clipboard to be used as another string...
I'm scanning a barcode. The barcode reader appends tick symbols at the start and end of the barcode. I remove those, then remove the first few characters from the now numeric (no other symbols or text, just numbers), and before I remove the last two characters from the string I want to copy them to another cell, they are important in their own right. I've got most of it working so far but I'm stuck on the copy and paste of the last two characters. Here's what I'm working with so far... Any direction is always greatly appreciated.
VBA Code:
Option Explicit
Sub EnterTheScan()
Dim Barcode, LMBarcode As String
Dim DateEntered As Date
Dim ws As Worksheet, ws2 As Worksheet
Dim lRow As Long
With ThisWorkbook
Set ws = .Worksheets("DataEntry")
Set ws2 = .Worksheets("Details")
End With
lRow = ws2.Range("A" & Rows.Count).End(xlUp).Row
ws.Range("B3").Copy
ws2.Range("A" & lRow + 1).PasteSpecial xlPasteValues
ws2.Range("A" & lRow).Replace what:="`", Replacement:="", _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=True, _
SearchFormat:=False, ReplaceFormat:=False
lRow = ws2.Range("A" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
Barcode = ws2.Range("A" & lRow).Value
LMBarcode = Right(Barcode, Len(Barcode) - 4)
LMBarcode = Mid(LMBarcode, 1, Len(LMBarcode) - 3)
ws2.Range("B" & lRow).Value = LMBarcode
ws2.Range("D" & lRow).Value = Date
ws2.Range("E" & lRow).Value = Now()
ws2.Range("G2").Value = ws2.Range("B" & lRow).Value
Application.CutCopyMode = False
ws.Range("E4").Value = lRow - 1
ws.Range("B3").ClearContents
ws.Range("B3").Select
Application.ScreenUpdating = True
Exit Sub
End Sub