Excel Automatically Restarted

himaruasuka

New Member
Joined
May 26, 2022
Messages
12
Office Version
  1. 2013
Platform
  1. Windows
  2. Mobile
Good day! I need some help, I'm nearly done with my excel sheet but what just happen now was, when I submit the Data Entry, it will added to the list, but after that, I noticed some irregularities, like can't use the combobox, can't type, can't scroll, and after 1 minute, my excel file is automatically restarted. It seems that there is some error in my codes because when I added it, i only get this error.

VBA Code:
Private Sub pos_checkout_Click()

    ' For Validation
    If pos_cmbx_name.Value = "" Then
    MsgBox "Please Select Product", vbCritical
    Exit Sub
    End If

    If pos_quantity.Value = "" Then
    MsgBox "Please Enter Quantity", vbCritical
    Exit Sub
    End If

    If pos_customer.Value = "" Then
    MsgBox "Please Enter Customer Name", vbCritical
    Exit Sub
    End If

    If pos_address.Value = "" Then
    MsgBox "Please Enter Customer's Address", vbCritical
    Exit Sub
    End If

    If pos_contact.Value = "" Then
    MsgBox "Please Enter Customer's Contact", vbCritical
    Exit Sub
    End If

    If pos_other.Value = "" Then
    MsgBox "Please Enter Customer's Other Contact", vbCritical
    Exit Sub
    End If
    
    
    Worksheets("Home").Unprotect "Roshier"
    Dim ans As Integer
    ans = MsgBox("Order will be added in the queue, you want to proceed?", vbQuestion + vbYesNo + vbDefaultButton2, "Order Validation")
    If ans = vbYes Then
        
    Dim sh As Worksheet
    Set sh = ActiveWorkbook.Sheets("Home")
    Dim LR As Long
    Dim table2 As ListObject
    
    LR = Sheets("Home").Range("E" & Rows.Count).End(xlUp).Row
    
        Set table2 = sh.ListObjects("Table1356")
    
        Dim lr2 As ListRow
        Set lr2 = table2.ListRows.add
    
        With lr2
            .Range(2).Value = pos_form.pos_orderno.Value
            .Range(3).Value = pos_form.pos_date.Value

            .Range(4).Value = pos_form.pos_cmbx_name.Value

            .Range(5).Value = pos_form.pos_category.Value
            .Range(6).Value = pos_form.pos_quantity.Value
            .Range(7).Value = pos_form.pos_price.Value

            .Range(8).Value = pos_form.pos_customer.Value
            .Range(9).Value = pos_form.pos_address.Value
            .Range(10).Value = pos_form.pos_contact.Value
            .Range(11).Value = pos_form.pos_other.Value

            If pos_form.pos_cod.Value Then .Range(15).Value = "COD/CASH"
            If pos_form.pos_gcash.Value Then .Range(15).Value = "G-CASH"

        End With


            pos_form.pos_orderno.Value = ""
            pos_form.pos_date.Value = ""

            pos_form.pos_cmbx_name = ""

            pos_form.pos_category.Value = ""
            pos_form.pos_quantity.Value = ""
            pos_form.pos_price.Value = ""

            pos_form.pos_customer.Value = ""
            pos_form.pos_address.Value = ""
            pos_form.pos_contact.Value = ""
            pos_form.pos_other.Value = ""

            pos_form.pos_cod.Value = False
            pos_form.pos_gcash.Value = False
            
    Worksheets("Home").Protect "Roshier"
            Unload pos_form
            Exit Sub
    

    Else
        MsgBox "Check the details carefully!"
    End If

End Sub

This is the Entry Form
Capture2.PNG


This is the Datasheet
Capture32.PNG


and I also noticed some problem, in range(1), I have put some Conditional Formatting to put a color.. Delivered as grey, Pending as Red, For Delivery as Green.. But when I added some data in the queue, the color is malfunctioning? all data I put in: delivered, pending, for delivery, it appears to always color green. What happen? anyone who could help me? Thanks in Advance !
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Good day! I need some help, I'm nearly done with my excel sheet but what just happen now was, when I submit the Data Entry, it will added to the list, but after that, I noticed some irregularities, like can't use the combobox, can't type, can't scroll, and after 1 minute, my excel file is automatically restarted. It seems that there is some error in my codes because when I added it, i only get this error.

VBA Code:
Private Sub pos_checkout_Click()

    ' For Validation
    If pos_cmbx_name.Value = "" Then
    MsgBox "Please Select Product", vbCritical
    Exit Sub
    End If

    If pos_quantity.Value = "" Then
    MsgBox "Please Enter Quantity", vbCritical
    Exit Sub
    End If

    If pos_customer.Value = "" Then
    MsgBox "Please Enter Customer Name", vbCritical
    Exit Sub
    End If

    If pos_address.Value = "" Then
    MsgBox "Please Enter Customer's Address", vbCritical
    Exit Sub
    End If

    If pos_contact.Value = "" Then
    MsgBox "Please Enter Customer's Contact", vbCritical
    Exit Sub
    End If

    If pos_other.Value = "" Then
    MsgBox "Please Enter Customer's Other Contact", vbCritical
    Exit Sub
    End If
  
  
    Worksheets("Home").Unprotect "Roshier"
    Dim ans As Integer
    ans = MsgBox("Order will be added in the queue, you want to proceed?", vbQuestion + vbYesNo + vbDefaultButton2, "Order Validation")
    If ans = vbYes Then
      
    Dim sh As Worksheet
    Set sh = ActiveWorkbook.Sheets("Home")
    Dim LR As Long
    Dim table2 As ListObject
  
    LR = Sheets("Home").Range("E" & Rows.Count).End(xlUp).Row
  
        Set table2 = sh.ListObjects("Table1356")
  
        Dim lr2 As ListRow
        Set lr2 = table2.ListRows.add
  
        With lr2
            .Range(2).Value = pos_form.pos_orderno.Value
            .Range(3).Value = pos_form.pos_date.Value

            .Range(4).Value = pos_form.pos_cmbx_name.Value

            .Range(5).Value = pos_form.pos_category.Value
            .Range(6).Value = pos_form.pos_quantity.Value
            .Range(7).Value = pos_form.pos_price.Value

            .Range(8).Value = pos_form.pos_customer.Value
            .Range(9).Value = pos_form.pos_address.Value
            .Range(10).Value = pos_form.pos_contact.Value
            .Range(11).Value = pos_form.pos_other.Value

            If pos_form.pos_cod.Value Then .Range(15).Value = "COD/CASH"
            If pos_form.pos_gcash.Value Then .Range(15).Value = "G-CASH"

        End With


            pos_form.pos_orderno.Value = ""
            pos_form.pos_date.Value = ""

            pos_form.pos_cmbx_name = ""

            pos_form.pos_category.Value = ""
            pos_form.pos_quantity.Value = ""
            pos_form.pos_price.Value = ""

            pos_form.pos_customer.Value = ""
            pos_form.pos_address.Value = ""
            pos_form.pos_contact.Value = ""
            pos_form.pos_other.Value = ""

            pos_form.pos_cod.Value = False
            pos_form.pos_gcash.Value = False
          
    Worksheets("Home").Protect "Roshier"
            Unload pos_form
            Exit Sub
  

    Else
        MsgBox "Check the details carefully!"
    End If

End Sub

This is the Entry Form
View attachment 66284

This is the Datasheet
View attachment 66287

and I also noticed some problem, in range(1), I have put some Conditional Formatting to put a color.. Delivered as grey, Pending as Red, For Delivery as Green.. But when I added some data in the queue, the color is malfunctioning? all data I put in: delivered, pending, for delivery, it appears to always color green. What happen? anyone who could help me? Thanks in Advance !

additional info.
this is what the color looks like when I submit data in the queue. The previous data after I enter another data, I get the proper color but the newly added is not.
Capture32.PNG


and now, restarted.
1654328087420.png
1654328117765.png
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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