I'm working on a project which contains multiple columns containing Batch no.& their Quantities.
I have used a VBA code which helps me automatically input the Batch Qty.
So i want to update the 'Product_In' Range of Vlookup for Multiple columns i.e. D:E, K:L, R:S, Y:Z etc
Is their a way to do that??
Any help is appreciated
I have used a VBA code which helps me automatically input the Batch Qty.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim check
Dim cl As Range
Dim mx As Double
Dim nx As Double
Dim batch
Dim rng As Range
Dim Rg As Range
ActiveSheet.Unprotect "FGIM@22"
For Each cl In Target.Cells
' Check to see if "Product_In" entry made in column G
If Target.Column = 10 And Target.Offset(0, -3).Value = "Product_In" Then
Application.EnableEvents = False
' Lookup value from Batch Register sheet and place in column J
batch = Target.Offset(0, -6)
Set Rg = Sheets("Batch Card REGISTER").Range("D:E")
nx = Application.WorksheetFunction.VLookup(batch, Sheets("Batch Card REGISTER").Range("D:E"), 2, False)
' Limit entry to maximum allowed
If Target.Value And nx <> Target.Value Then
MsgBox "Value in Batch card Register does not match" & VBA.Constants.vbNewLine & "Orginal Value will be Entered", vbOKOnly, "ENTRY ERROR!"
Target.Value = nx
End If
Application.EnableEvents = True
End If
' Verify entry in column J when "Dispatch" in is column G
If Target.Column = 10 And Target.Offset(0, -3).Value = "Dispatch" Then
Application.EnableEvents = False
' Lookup value maximum allowable value from "FG Register" sheet
batch = Target.Offset(0, -6)
Set rng = Sheets("FG Register").Columns("D:I")
mx = Application.WorksheetFunction.VLookup(Target.Offset(0, -6), Sheets("FG Register").Columns("D:I"), 6, False)
' Limit entry to maximum allowed
If Target.Value And mx < 0 Then
MsgBox "Value in Current Stock cannot exceed " & mx, vbOKOnly, "ENTRY ERROR!"
Target.Value = Target.Value + mx
End If
Application.EnableEvents = True
End If
If Target.Column = 10 Then
check = MsgBox("NOTE: CANNOT be edited after confirmation, Confirm the Entry?", vbYesNo, "Confirm Entry")
If check = vbYes Then
Range("A" & cl.Row & ":J" & cl.Row).Locked = True
Else
Range("C" & cl.Row & ":H" & cl.Row).Locked = False
End If
End If
Next cl
If Not Intersect(Target, Me.Range("A1:AA1000")) Is Nothing Then
ThisWorkbook.Save
End If
End Sub
So i want to update the 'Product_In' Range of Vlookup for Multiple columns i.e. D:E, K:L, R:S, Y:Z etc
Is their a way to do that??
Any help is appreciated