Excel Crashing Between VBA Message Boxes?

imay3kbug

New Member
Joined
May 31, 2012
Messages
2
Hi All,

I'm pretty new to VBA so I'm hoping someone can point and laugh at my mistake and tell me what's going on.

I'm using Excel 2010 on a Windows 7 (x64 pro) machine. I have the following code:

Code:
Sub UpdateGroup()
Dim Count As Long
Dim TextNum As String

UpdateGrp = True
Application.ScreenUpdating = False
YesError = False ' This is setup so if a group isn't found after hitting update, the sub doesn't incorrectly fill fields
Call FindGroup
'Load UserForm1
If ActiveCell.Value = "" Or SearchName = "" Then
    Sheets("Display").Activate
    Exit Sub
End If
If YesError = True Then ' If no company is found after hitting update button, then it acts as a new group
    Call ShowUserform
    Sheets("Display").Activate
    Exit Sub
End If
Sheets("Records").Activate
    For Count = 1 To 236
        TextNum = "Textbox" & Count
        UserForm1.Controls(TextNum).Value = ActiveCell.Offset(0, Count).Value
    Next Count
MsgBox "Userform command buttion is visible = " & UserForm1.CommandButton1.Visible 'debugging message
    UserForm1.CommandButton1.Visible = False
MsgBox "Userform command buttion is visible = " & UserForm1.CommandButton1.Visible 'debugging message

'Crash will appear here even between the two message boxes

MsgBox "ComboBox 1 value is now: " & UserForm1.ComboBox1.Text 'debugging message
    UserForm1.ComboBox1.Text = UserForm1.TextBox72.Text
MsgBox "ComboBox 1 value is now: " & UserForm1.ComboBox1.Text 'debugging message
    UserForm1.ComboBox2.Text = UserForm1.TextBox132.Text
    UserForm1.ComboBox3.Text = UserForm1.TextBox181.Text
MsgBox "Combo boxes now loaded"
UserForm1.Show
Application.ScreenUpdating = True

End Sub
When the code reaches the point where the comment about crashing is, Excel crashes. Originally I didn't have all the message boxes you see, but I added them to debug. As you can see, the crash will happen even between just two message boxes. The first one will appear, I click "okay" and then before the second one will appear, the whole application crashes.

At first I thought it might be related to something in the Userform that I'm setting up, but since it still occurs between message boxes, I'm thinking the UserForm is unrelated?

I have found a workaround, if the file is saved before running the procedure, then it works fine. I have temporarily set it up to save when the file opens, but as the file gets larger over time, that may not be a long term solution.

As I said, I'm hoping it's something stupid simple that I missed. Any Ideas?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
So it looks like the crash is related to the Userform after after all.
I've been digging more and have figured out that the bug has something to do with the Comboboxes on my UserForm. When they're there, the bug is there. If I delete the Comboboxes, then the crash does not happen.

Any ideas on why a Combobox might cause Excel to crash? Is it possible I should be setting something on them that I don't and then when the file is saved that setting is "reset"?
 
Upvote 0

Forum statistics

Threads
1,203,060
Messages
6,053,303
Members
444,650
Latest member
bookendinSA

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