VBA Macro makes Excel crash... what are the causes to investigate?

Malkavian

New Member
Joined
Jul 22, 2010
Messages
16
Hi!

So I made this big business program that basicly import huge data tables from an Access database to Excel sheets. The user enter a group number in input and the datas of that specific group are shown on the userform. The program allows to add, remove and edit groups and those modifications are exported back to the Access database. The program is HUGE. I have hundreds of textboxes and thousands of lines of datas.

Everything worked fine but now, one button makes Excel crash... I can't figure what's the problem is since when I run the macro assigned to that button step by step (with F8), the macro runs just fine. :eek:

What should I investigate?? Never had this kind of issue with VBA before... :confused:
 
It wasn't working because it was refering to Userform1 most likely.

this should work just fine:

Code:
Dim c As Control
    For Each c In UserForm2.Controls
        If c.Name Like "TextBox" Then c.Text = ""
    Next c
UserForm2.Hide
UserForm1.Show


Nah I assure you that my code was correctly referring to Userform2. You probably saw the Userform1 reference in VoG's code. ;)
 
Upvote 0

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Weird. I just made up a Userform called Userform2, Placed a couple of Textboxes and a button there and the code:


Code:
Private Sub CommandButton1_Click()
Dim c As Control
    For Each c In UserForm2.Controls
        If c.Name Like "TextBox*" Then c.Text = ""
    Next c
End Sub

ran just fine. In my last post I forgot to include the * in If c.Name Like "TextBox*" Then c.Text = ""

Which line did it bug out at when you were testing it?
 
Upvote 0
Weird to know that it worked for you!

See my previous post :

...
It never enters the procedure if... VBA doesn't seem to be recognizing the wildcard caracter (*) properly. However, if I replace "TextBox*" by "TextBox1" it goes in and works for that specific TextBox :eek:. So the issue has to be with the *.
...

It didn't "bug out", it just never even entered the If procedure...!
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

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