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
 
You also don't need to do any selecting, which can also be a culprit in code failure:

Code:
    With Sheets("Sheet1")
        With .Range("A3")
            .EntireRow.Insert
            .Value = TextBox1.Value
        End With
        Range("B3").Value = TextBox2.Value
        Range("C3").Value = TextBox3.Value
        Range("D3").Value = TextBox4.Value
    End With

HTH,
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,215,430
Messages
6,124,847
Members
449,194
Latest member
HellScout

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