Run Time error 28 - Out of stack space????

danbates

Active Member
Joined
Oct 8, 2017
Messages
261
Hi,

Please can someone help me?

I have the following code which is triggering Run Time error 28 - Out of stack space.

This is the only code in my workbook as well.

How can I clear this error?

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Range("B2").Value <> "" Then
Range("R2").Value = Format(Date, "mm/dd/yyyy")
End If
End Sub
Thanks

Dan
 

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,692
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
If you change a cell in a Change event, you'll trigger the event again, hence the problem. You need to temporarily disable events:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Range("B2").Value <> "" Then
application.enableevents = false
Range("R2").Value = Format(Date, "mm/dd/yyyy")
application.enableevents = true
End If
End Sub
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,090,109
Messages
5,412,473
Members
403,428
Latest member
ldmcd

This Week's Hot Topics

Top