Q: Wrongly Triggered Function Apologies if this is too vague, but I can't find an answer online. I have a Worksheet Change sub that runs OK, and I'm developing it to do more. Weird thing is, as I step through code, it's manipulating one sheet which has no ties to another sheet, other than they're in the same workbook.
However, a UDF I have used in the other unrelated sheet runs as I'm stepping through my code.
Not sure what code to paste. This is the code (a sub triggered from another sub in a change event) that's triggering the UDF when I get to the Resize line, but other code seems to do it also.
Sub QCPSIRCoverAdd(tr As Integer, tv As String, tic As Integer)
Dim rwPN As Range
Dim arrPN As Range

Set rwPN = shQCPSIRC.Rows(shQCPSIRC.Columns(1).Find("Part No.").Row)
rwPN.Offset(1) = rwPN.Resize(1)


rwPN.EntireRow.Offset(tic).Resize(10).Insert
shQCPSIRC.Cells(tr + 11, 1) = tv

End Sub

Any thoughts why changes in one sheet, would trigger a UDF to run in another, which isn't getting info from the sheet I'm modifying?
I'm pretty certain they don't share any variables.
Below is the UDF being triggered
Function Sample(IL As String, Batch As Long) As Long

If IL = "S-1" Then
    Select Case Batch
    Case 2 To 50
        Sample = 2
    Case 51 To 500
        Sample = 3
    Case 501 To 35000
        Sample = 5
    Case Is >= 35001
        Sample = 8
    End Select
End If

If IL = "S-2" Then
Select Case Batch
    Case 2 To 25
        Sample = 2
    Case 26 To 150
        Sample = 3
    Case 151 To 1200
        Sample = 5
    Case 1201 To 35000
        Sample = 8
    Case Is >= 35001
        Sample = 13
End Select
End If

If IL = "S-3" Then
Select Case Batch
    Case 2 To 15
        Sample = 2
    Case 16 To 50
        Sample = 3
    Case 51 To 150
        Sample = 5
    Case 151 To 500
        Sample = 8
    Case 501 To 3200
        Sample = 13
    Case 3201 To 35000
        Sample = 20
    Case 35001 To 500000
        Sample = 32
    Case Is >= 500001
        Sample = 50
End Select
End If

If IL = "S-4" Then
Select Case Batch
    Case 2 To 15
        Sample = 2
    Case 16 To 25
        Sample = 3
    Case 26 To 90
        Sample = 5
    Case 91 To 150
        Sample = 8
    Case 151 To 500
        Sample = 13
    Case 501 To 1200
        Sample = 20
    Case 1201 To 10000
        Sample = 32
    Case 10001 To 35000
        Sample = 50
    Case 35001 To 500000
        Sample = 80
    Case Is >= 500001
        Sample = 125
End Select
End If

If IL = "G-1" Then
Select Case Batch
    Case 2 To 15
        Sample = 2
    Case 16 To 25
        Sample = 3
    Case 26 To 90
        Sample = 5
    Case 91 To 150
        Sample = 8
    Case 151 To 280
        Sample = 13
    Case 281 To 500
        Sample = 20
    Case 501 To 1200
        Sample = 32
    Case 1201 To 3200
        Sample = 50
    Case 3201 To 10000
        Sample = 80
    Case 10001 To 35000
        Sample = 125
    Case 35001 To 150000
        Sample = 200
    Case 150001 To 500000
        Sample = 315
    Case Is >= 500001
        Sample = 500
End Select
End If

If IL = "G-2" Then
Select Case Batch
    Case 2 To 8
        Sample = 2
    Case 9 To 15
        Sample = 3
    Case 16 To 25
        Sample = 5
    Case 26 To 50
        Sample = 8
    Case 51 To 90
        Sample = 13
    Case 91 To 150
        Sample = 20
    Case 151 To 280
        Sample = 32
    Case 281 To 500
        Sample = 50
    Case 501 To 1200
        Sample = 80
    Case 1201 To 3200
        Sample = 125
    Case 3201 To 10000
        Sample = 200
    Case 10001 To 35000
        Sample = 315
    Case 35001 To 150000
        Sample = 500
    Case 150001 To 500000
        Sample = 800
    Case Is >= 500001
        Sample = 1250
End Select
End If

If IL = "G-3" Then
Select Case Batch
    Case 2 To 8
        Sample = 3
    Case 9 To 15
        Sample = 5
    Case 16 To 25
        Sample = 8
    Case 26 To 50
        Sample = 13
    Case 51 To 90
        Sample = 20
    Case 91 To 150
        Sample = 32
    Case 151 To 280
        Sample = 50
    Case 281 To 500
        Sample = 80
    Case 501 To 1200
        Sample = 125
    Case 1201 To 3200
        Sample = 200
    Case 3201 To 10000
        Sample = 315
    Case 10001 To 35000
        Sample = 500
    Case 35001 To 150000
        Sample = 800
    Case 150001 To 500000
        Sample = 1250
    Case Is >= 500001
        Sample = 2000
End Select
End If
End Function

