how to retrict excel from closing while remotely entering data

jiaweilee

New Member
Joined
Mar 26, 2016
Messages
13
I already ask the user to key In ID and the cell will be select automatically. next is how to prevent the excel from closing when data is key in remotely in the selected column?

Code:
Sub Enter_1()
Dim data_1 As String
Dim sCell As Variant
Dim rslt As Integer
Dim x As Integer

Do
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    data_1 = InputBox(Prompt:="Enter Employee No.", Title:="Employee", Default:="Enter Employee No. here")
    
    If data_1 = "" Then
        QuestionToMessageBox = "Exit?"
        YesOrNoAnswerToMessageBox = MsgBox(QuestionToMessageBox, vbYesNo, "No")
    End If
    
    If YesOrNoAnswerToMessageBox = vbNo Then
    
        data_1 = InputBox(Prompt:="Enter Employee No.", Title:="Employee", Default:="Enter Employee No. here")
        
    Exit sub    
    End If
  
        If Not IsNumeric(data_1) Or data_1 = "" Then
            rslt = 0
        Else: rslt = 1
        End If
        
        If rslt = 0 Then
         MsgBox "You can only enter a number in this field"
        
        Else:
            Sheets("Oven After Assay Test").Activate
            For x = 6 To 50
                If Cells(x, 8).Value = "" Then
                    Cells(x, 8).Select
                    cancel = True
                    Exit For
                End If
            Next
        End If
 
    Loop While rslt = 0
    


End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
do you have a shut down timer running ?
 
Upvote 0
not sure what would cause the application to close then
 
Upvote 0
I try to do this but it does not work by adding

Code:
Public Closeflag As Boolean
Sub Enter_1()
Closeflag = False
/code
Closeflag = True
End sub


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Workbook_BeforeClose(Cancel As Boolean)


If Closeflag = False Then Exit Sub
Cancel = True



End Sub
 
Upvote 0
You could try the following.

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Not bCloseOK Then
MsgBox "Close button disabled"
Cancel = True
End If
End Sub

Although if you do this, excel won't be able to close except for killing the task.

Might want to think about adding a button or another macro to close the program.
 
Last edited:
Upvote 0
did you mean that remote users are closing the file before they have finished actually updating the values they are responsible for
 
Upvote 0
There is such situation when remote user is key in data using a Bluetooth barcode scanner away from the PC and other users try to close the excel file. Then all the value key in will be loss
 
Upvote 0
You could try the following.

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Not bCloseOK Then
MsgBox "Close button disabled"
Cancel = True
End If
End Sub

Although if you do this, excel won't be able to close except for killing the task.

Might want to think about adding a button or another macro to close the program.

//
I try to do this before but still be able to close the excel by selecting don't save
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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