Question: I have added a message box using the code 

```
If MsgBox("File has been updated", vbinformatoin) = ok Then Exit Sub

```

on to a command button used to update the spreadsheet and save to another sheet.

If the command button were not to work for some reason would this message still appear? and if so how can I change to message box so it only works when the spreadsheet has definitely updated?

Answer: 
What you need is an error handler. You need to set at the beginning of your sub an "On Error" statement and then write an error handler.

Here is a ressource where you can find information on how to set it up : <https://support.microsoft.com/en-us/kb/141571#/en-us/kb/141571>

Your code would be then like this

```
Sub mySub()
  On Error GoTo CatchError 'I called it CatchError but you can call it whatever

  '--All of your code here including "If MsgBox("File has been updated", vbinformatoin) = ok Then Exit Sub"

CatchError:
  'Here put what you want to do in case of an error, for example
  'MsgBox "The code stopped because of an error"
End Sub

```
I'm not sure if this fully answers your question but you could try this:  

(NB.Substitute the relevant code in place of the message box)

```
Private change_ind As Integer
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
   change_ind = 1
End sub
Private Sub CommandButton1_Click()
   If change_ind = 1 Then
       MsgBox "Update has occurred"
       Else
      &nbsp;    MsgBox "No updates"
     End If
End Sub

```