I have a spreadsheet with an external data table coming from SQL Server with a query that returns data specific to each user. I have put instructions in this file to allow it to download once and then to unlink it.

Unfortunately one user didn't, added a whole heap of data, "saved" and has lost their work.

Is there any way to get the data back?

1 Answer 1


Sorry, you are out of luck. Since you have "Remove data from the external date range before saving the workbook" checked the added data was never saved and there is no place to retrieve the user's data from.

To prevent this kind of accident going forward, I would change the workbook to macro enabled(.xlsm), if it isn't already, and add a check in the BeforeSave event to see if the table has been unlinked.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
   Dim sMsg As String

   ' Assuming the data table is the first table on the first worksheet
   With Worksheets(1).ListObjects(1)  

      If .SourceType <> xlSrcRange Then
         sMsg = "Any changes you've made to the table won't be saved unless you unlink from the database!" _
               & vbCrLf & vbCrLf & "Do you want to unlink?"
         If MsgBox(sMsg, vbExclamation + vbYesNo) = vbYes Then
         End If
      End If

   End With

End Sub
  • Ah well, it was a long shot to begin with. Thanks for the macro though! =)
    – Fowl
    Jan 25, 2012 at 4:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.