JumboCactuar
Well-known Member
- Joined
- Nov 16, 2016
- Messages
- 785
- Office Version
- 365
- Platform
- Windows
Hi,
I have the following which basically works like a vlookup
(When data is entered / scanned into column A ,
B,C,D is filled from another sheet
Though when scanned fast, there is noticeable lag between each cell.
Is there any better ways to do this? Maybe store the lookup data in array so worksheet is not referenced
Thanks for any help
I have the following which basically works like a vlookup
(When data is entered / scanned into column A ,
B,C,D is filled from another sheet
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Item As String
Dim LookupResult As Range
If Target.Cells.Count > 1 Then Exit Sub
If Target = "" Then Exit Sub
If Left(Target.Address, 3) = "$A$" Then
Application.EnableEvents = False
Application.ScreenUpdating = False
Item = Target.Value
With Sheets("Data")
Set LookupResult = .Columns(1).Find(What:=Item, After:=.Cells(1, 1) _
, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows _
, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
On Error GoTo 0
If Not LookupResult Is Nothing Then
Target.Offset(0, 1).Value = LookupResult.Offset(0, 1).Value
Target.Offset(0, 2).Value = LookupResult.Offset(0, 2).Value
Target.Offset(0, 3).Value = LookupResult.Offset(0, 3).Value
Target.Offset(0, 4).Value = LookupResult.Offset(0, 4).Value
Else
End If
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
Else
End If
End Sub
Though when scanned fast, there is noticeable lag between each cell.
Is there any better ways to do this? Maybe store the lookup data in array so worksheet is not referenced
Thanks for any help