Excel freezing during Macro

Alpharooms

New Member
Joined
Oct 31, 2010
Messages
7
Hi All,

Not a complete novice but not an expert eith when it comes to VB in excel, most things i have managed to do but for some reason when im posting information from a userform to a work sheet, excel freezes and has to be closed from task manager, i have stripped the codeing down to see whats cuase it to freeze but it still does it any sugegstions? i have posted the codeing below:

Code:
Sub Add()
Sheet1.Select
Range("A3").Select
ActiveCell.EntireRow.Insert
Range("A3").Value = TextBox1.Value
Range("B3").Value = TextBox2.Value
Range("C3").Value = TextBox3.Value
Range("D3").Value = TextBox4.Value
Range("E3").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-1]-RC[-2])"
Range("F3").Value = ComboBox1.Value
Range("G3").Value = ComboBox2.Value
Sheet3.Select
UserForm1.Hide
UserForm6.Show
Exit Sub
End Sub
Private Sub CommandButton1_Click()
If TextBox2.Value = "" Then MsgBox "Please Enter Invoice ID" Else
If TextBox3.Value = "" Then MsgBox "Please Enter Amount Paid" Else
If TextBox4.Value = "" Then MsgBox "Please Enter Amount Recieved" Else
If ComboBox1.Value = "" Then MsgBox "Please Enter A Reason!" Else
If ComboBox2.Value = "" Then MsgBox "Please Enter Your Staff Initials" Else Add
Exit Sub
End Sub

any suggestions as to why excel would freeze when doing this?

just trying to made things easyer at work and i seem to be getting stuck on this. this is not for profit but to keep a log on compensation and card payments ect to stop people entering n the forms wrong, any help would be good.

Thanks

Bobby
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Place breakpoints on each line of code and step through it. When it freezes, you'll at least know which line of code is causing it, then we can try to work out why.
 
Upvote 0
as soon as i put the following code on:

Code:
Application.ScreenUpdating = False

at the beggining it worked im asuming excel could coult not update quick enothe and there for hangged strange really lol but solved lol
 
Upvote 0
im asuming excel could coult not update quick enothe

I don't know if that's the issue, so you may just be masking the true error (if there is one). I'd follow the previous suggestion and step throught the code. You can add a breakpoint with F9 and you can step through the code line by line by hitting F8. Your code's short enough that stepping through should be fine by itself though.
 
Upvote 0
I did do that and each part of the code worked fine with out an issue, thats when a friend of mine suggested the above, he said it uses less processing power thro excel as its not being displayed to the user, again it seems to work now so unsure as to why??
 
Upvote 0
I agree with Smitty that Application.... might not be the reason it worked/didn't work.

The first thing I saw was the use of Add for the sub's name.

Add is a method of absolutely loads of things in Excel, so it's best not to use it.
 
Upvote 0

Forum statistics

Threads
1,214,922
Messages
6,122,281
Members
449,075
Latest member
staticfluids

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