Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 0 down vote accepted

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
share|improve this answer
Ah well, it was a long shot to begin with. Thanks for the macro though! =) – Fowl Jan 25 '12 at 4:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .