This code works but once I trying updating a cell the code stops working.
here is the code:
here is the code:
Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Call Macro1(Target)
Call Macro2(Target)
Call Macro3(Target)
Call Macro4(Target)
Call Macro5(Target)
End Sub
Sub Macro1(ByVal Target As Range)
If Target.Cells.Count > 1 Then GoTo exitHandler
If Target.Column = 1 Then
If Target.Value = "" Then GoTo exitHandler
Application.EnableEvents = False
Target.Value = Worksheets("DataEntry").Range("A1") _
.Offset(Application.WorksheetFunction _
.Match(Target.Value, Worksheets("DataEntry").Range("Site_Name_ID"), 0), 0)
End If
exitHandler:
Application.EnableEvents = True
Exit Sub
End Sub
Sub Macro2(ByVal Target As Range)
If Target.Cells.Count > 1 Then GoTo exitHandler
If Target.Column = 2 Then
If Target.Value = "" Then GoTo exitHandler
Application.EnableEvents = False
Target.Value = Worksheets("DataEntry").Range("D1") _
.Offset(Application.WorksheetFunction _
.Match(Target.Value, Worksheets("DataEntry").Range("Grant_Code_ID"), 0), 0)
End If
exitHandler:
Application.EnableEvents = True
Exit Sub
End Sub
Sub Macro3(ByVal Target As Range)
If Target.Cells.Count > 1 Then GoTo exitHandler
If Target.Column = 3 Then
If Target.Value = "" Then GoTo exitHandler
Application.EnableEvents = False
Target.Value = Worksheets("DataEntry").Range("G1") _
.Offset(Application.WorksheetFunction _
.Match(Target.Value, Worksheets("DataEntry").Range("Area_of_Info_ID"), 0), 0)
End If
exitHandler:
Application.EnableEvents = True
Exit Sub
End Sub
Sub Macro4(ByVal Target As Range)
If Target.Cells.Count > 1 Then GoTo exitHandler
If Target.Column = 4 Then
If Target.Value = "" Then GoTo exitHandler
Application.EnableEvents = False
Target.Value = Worksheets("DataEntry").Range("J1") _
.Offset(Application.WorksheetFunction _
.Match(Target.Value, Worksheets("DataEntry").Range("Source_Name_ID"), 0), 0)
End If
exitHandler:
Application.EnableEvents = True
Exit Sub
End Sub
' QRCode VBA
Sub Macro5(ByVal Target As Range)
Dim r As Range, c As Range
On Error Resume Next
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
Set r = Intersect(ActiveSheet.Columns(6).Precedents, Target)
If r Is Nothing Then Exit Sub
For Each c In r.Rows
With c
ActiveSheet.Shapes("QR " & .Row).Delete
QRcodeToPicUTF8 Cells(.Row, "F"), Environ("temp"), _
"QR " & .Row, Cells(.Row, "G")
End With
Next c
EndSub:
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
End With
End Sub
Last edited by a moderator: