Combine multiple macros on one worksheet

nkendri24

New Member
Joined
May 22, 2018
Messages
16
This code works but once I trying updating a cell the code stops working.
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:

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Just a quick glance at your code so this may not be sufficient.

Try replacing this line in Macro5:

If r Is Nothing Then Exit Sub

with this:

If r Is Nothing Then GoTo EndSub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,179
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top