killaej6
New Member
- Joined
- May 22, 2021
- Messages
- 7
- Office Version
- 365
- 2016
- 2013
- 2011
- 2010
- 2007
- Platform
- Windows
Hello everyone....
I am in need of some advice.
I have a code ( Worksheet_Selection Change) where i scan the barcode into the application.inputbox and then the value in the application.inputbox is returned to a fixed cell column. ( Column E).
If the user clicks "Cancel" then sub exits. the code is reactivated through the command button which i have placed.
The code runs fine until around the 80th-ish, 90th-ish, entry. On these entries the return value jumps to Column A.
The command button also stops responding after the 80th -ishh, 90th-ishh entry.
On top of this, all other excel functions like ( "File", "Edit", Closing the workbook becomes unresponsive). I will then need to shutdown the workbook using Task manager and restart the workbook. The code then runs fine until another 90++ entry which the problem occurs again.
Hope my explanation of the issue is clear to all. Do let me know if need any other info.
Appreciate the support guys..
P/S : My code as shown below. and i have attached an image to visualize my problem.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Scan4 As Variant
Dim lr As Long
On Error GoTo presscancel
Sheets("Scan Here").Select
ActiveSheet.Unprotect Password:="henry"
Application.EnableEvents = False
Scan4 = Application.InputBox("Please scan the barcode")
If Scan4 = False Then
Application.EnableEvents = False
Else
Application.EnableEvents = True
lr = Workbooks("BATBarcode v1.xlsm").Sheets("Scan Here").Range("E" & Rows.Count).End(xlUp).Row + 1
Range("E" & lr).Value = Scan4
End If
Sheets("Scan Here").Select
ActiveSheet.Unprotect Password:="henry"
Range("A1:L500").Select
Selection.Locked = True
Selection.FormulaHidden = False
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Locked = False
Selection.FormulaHidden = False
Sheets("Scan Here").Select
ActiveSheet.Protect Password:="henry"
presscancel:
Exit Sub
End Sub
I am in need of some advice.
I have a code ( Worksheet_Selection Change) where i scan the barcode into the application.inputbox and then the value in the application.inputbox is returned to a fixed cell column. ( Column E).
If the user clicks "Cancel" then sub exits. the code is reactivated through the command button which i have placed.
The code runs fine until around the 80th-ish, 90th-ish, entry. On these entries the return value jumps to Column A.
The command button also stops responding after the 80th -ishh, 90th-ishh entry.
On top of this, all other excel functions like ( "File", "Edit", Closing the workbook becomes unresponsive). I will then need to shutdown the workbook using Task manager and restart the workbook. The code then runs fine until another 90++ entry which the problem occurs again.
Hope my explanation of the issue is clear to all. Do let me know if need any other info.
Appreciate the support guys..
P/S : My code as shown below. and i have attached an image to visualize my problem.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Scan4 As Variant
Dim lr As Long
On Error GoTo presscancel
Sheets("Scan Here").Select
ActiveSheet.Unprotect Password:="henry"
Application.EnableEvents = False
Scan4 = Application.InputBox("Please scan the barcode")
If Scan4 = False Then
Application.EnableEvents = False
Else
Application.EnableEvents = True
lr = Workbooks("BATBarcode v1.xlsm").Sheets("Scan Here").Range("E" & Rows.Count).End(xlUp).Row + 1
Range("E" & lr).Value = Scan4
End If
Sheets("Scan Here").Select
ActiveSheet.Unprotect Password:="henry"
Range("A1:L500").Select
Selection.Locked = True
Selection.FormulaHidden = False
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Locked = False
Selection.FormulaHidden = False
Sheets("Scan Here").Select
ActiveSheet.Protect Password:="henry"
presscancel:
Exit Sub
End Sub