When you change the worksheet, try adding two special lines, for example:
Application.EnableEvents = False
Range("Y" & x).Value = tV
Application.EnableEvents = True
Do it for Range("AI1").ClearContents too.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
HI,
I'm having a problem figuring out how to get rid of out of stack error 28.
so what I have is someone scan inventory the target address is AI1 and it should copy to AI2 and it would clear after that by pushing a button called line Tag.
I'm fairly new to VBA, Thanks for help
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
'Range("AH1").Select
If Not Application.Intersect(Target, Range("$AI$1")) Is Nothing Then---->this is what error highlight
Range("AI1").Select
sV = Trim(Range("AI2").Value) 'Scan Value
For x = 3 To 306
cV = Range("C" & x).Value 'Check Value (Load Number)
If sV = 0 Then Exit Sub
If cV = sV Then
tV = Range("Y" & x).Value 'tag Count
tV = tV + 1
Range("Y" & x).Value = tV
x = 306
ElseIf x = 306 Then
MsgBox "Load Not Found", vbOKOnly, "SCAN ERROR"
End If
Next x
sV = ""
Range("AI1").Select
Range("AI1").ClearContents
End If
End Sub
When you change the worksheet, try adding two special lines, for example:
Application.EnableEvents = False
Range("Y" & x).Value = tV
Application.EnableEvents = True
Do it for Range("AI1").ClearContents too.