1

I try to a create a workbook for my requirement. The first sheet include a cell which type is 'Text' and it is for DATE value.

I add Workbook_Open method for set today date when open the workbook as shown below.

Private Sub Workbook_Open()
     Sheet1.Range("F6") = Date
End Sub

And I also add Worksheet_Change method for sheet of that cell. That is for validation check as below.

Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address = "$F$6" Then

        'Getting insertion date.
        insertionDate = Sheet1.Range("F6")

        'If date field is not empty
        If insertionDate <> "" Then

            Call MsgBox("Insertion Date must be inserted.")

        End If

    End If

End Sub

After that, I tested my code. When open the work book, I got the following error.

Run-time error '28': 
Out of stack space

When click 'Debug' button, the cursor shown at the first line of Worksheet_Change method.

I has tried everything what I thought. But nothing is going on. Help me. Thank You.

3 Answers 3

1

I got it with this code. It is not satisfied for me but my problem is solved.

Private Sub Worksheet_Change(ByVal Target As Range)

    Application.EnableEvents = False

    If Target.Address = "$F$6" Then

        'Getting insertion date.
        insertionDate = Sheet1.Range("F6")

        'If date field is not empty
        If insertionDate <> "" Then

            Call MsgBox("Insertion Date must be inserted.")

        End If

    End If

    Application.EnableEvents = True

End Sub
Sign up to request clarification or add additional context in comments.

2 Comments

May be your code struck in recursive trigger event.
No, I think that is cause of "Multiple Sub". Thanks for your advice.
0

Msgbox not need Call statement. Try to remove Call and test again. And I have some reference from https://support.microsoft.com/en-us/kb/126090?wa=wsignin1.0. Its may be explain your error.

Comments

0

Possible sources of error marked in the code

Option Explicit   ' Candidate

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$F$6" Then

        'Getting insertion date.
        Dim insertionDate as String   ' Candidate
        insertionDate = Sheet1.Range("F6").Text   ' Candidate

        'If date field is not empty
        If insertionDate <> "" Then
            MsgBox("Insertion Date must be inserted.")   ' Candidate
        End If

    End If
End Sub

Make sure you placed Worksheet_Change in the sheet module.

1 Comment

Actually, 'insertionDate' is declared as Public in other module. Thanks for your advice.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.