Out of Stack Space

lesleym

New Member
Joined
Jun 17, 2010
Messages
5
Can anyone help?!?!

The code below gives and Out of Stack Space error on the highlighted line. I've tried dimming the var at different levels incase that was the problem but it's not. This works in every other Sub in the workbook.

Any help would be appreciated.

Lesley

If Target.Address = "$B$5" Then
Dim ThisCell As String * 14
Dim MidValue As String * 1
ThisCell = Range("B5").Value
If ThisCell <> "" Then
MidValue = Mid(ThisCell, 9, 1)
If MidValue = "-" Then
ThisCell = UCase(ThisCell)
Range("B5").Value = ThisCell
Exit Sub
Else
ErrorStr = "Course code should be in the format XXXXXXXX-X101X"
ErrorBox (ErrorStr)
Range("B5").ClearContents
Range("B5").Select
End If
End If
Exit Sub
End If
 

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.
Are you doing this in a Change event? If so, you need to disable events as you are changing the cell value in your code and can end up stuck in a loop.
 
Upvote 0
I think you are stuck in an infinite loop. Try turning off events

Code:
Dim ThisCell As String * 14
Dim MidValue As String * 1
If Target.Address = "$B$5" Then
    Application.EnableEvents = False
    ThisCell = Range("B5").Value
    If ThisCell <> "" Then
        MidValue = Mid(ThisCell, 9, 1)
        If MidValue = "-" Then
            ThisCell = UCase(ThisCell)
            Range("B5").Value = ThisCell
        Else
            ErrorStr = "Course code should be in the format XXXXXXXX-X101X"
            ErrorBox (ErrorStr)
            Range("B5").ClearContents
            Range("B5").Select
        End If
    End If
    Application.EnableEvents = True
End If
 
Upvote 0

Forum statistics

Threads
1,213,538
Messages
6,114,218
Members
448,554
Latest member
Gleisner2

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