How to undo deletion of an excel sheet - excel

English may not sound natural using a translator. sorry. Going to the main topic, while working on Excel, I accidentally deleted a sheet from Excel and threw it away. Is there any way I can turn it around? I've learned that I can never turn back. I have already saved.
Tried to undo such as control + z. just didn't come back.

The only way I know is to open your backup copy of the spreadsheet.
When doing important tasks I always work on a copy - if the next step or process is successful then I make another copy. This way I have a "set" of copies being the historical backup.
Excel does warn you about the consequence of deleting a, or several, sheets.

If the Excel file is saved on OneDrive (or any other cloud) or Sharepoint, you can open an old version of the file and transfer the sheet to your recent file.
If you have saved it on your hard drive and your computer is set up to save backups you can right click the file, open the options menu. There you might then see a list of past versions, from which you can get back your sheet.

Related

Excel VBA: Export workbook without links to external data/convert formulas to its values

I have come to a problem that I had kind of sorted, but it came back to haunt me.
I have a set of Excel files with information (origin) that feed an aggregator/wrangler/chewer in Excel (workbook) and then I have a set of files, one for each subsidiary (output), that have the same structure (sheets, hyperlinks, headers) but only get the relevant info for that subsidiary.
Right now I have everything automated, I download, prepare the information and update the origin files, then the only thing I need to do is open and save all the other documents (aggregator/subsidiary exports) and I do it with VBA.
In order to distribute the subsidiary files I have to come up with something that can have the same structure as an Excel workbook, but doesn't have the links to the aggregator, or the subsidiaries won't be able to see the information as there will be #REF errors everywhere (even on some sheets headers).
The solution that I put in place was exporting the files as MHTML (Single File Web Page), as it managed to keep the sheets and hyperlinks and everything as intended, while only needing to "open [subsidiary file].xlsx & save as [subsidiary file].mht", but then I came to learn that it is only possible to open this file type in IE, which not everyone has access to.
Then my problem is that I need an alternative to this solution while using only "plain" solutions as the IT department won't allow me to use anything more than standard administrative tools (standard MS Office suite).
I tried to replicate the subsidiary files by copying and pasting every sheet, but then I cannot come up with a way to keep every formatting (mainly header width) as intended when pasting as "values", or as "values and source formatting", and this approach doesn't escalate well.
Do you know of a way of saving the file as is but without the formulas, or preventing them from updating when the file reopens (even if you say no to "update links" prompt sometimes some cells ate updated, don't know why), or some different approach?
The idea is to generate a file that no matter who the user is, and does, is able to see the information, and cannot screw the file/info in it, and if possible keeping it "easy" to update with a "simple" macro.
Kind regards,
Flávio

Cell references/formulas in Excel to other workbooks on Sharepoint don't update values

The problem
I have eight Excel documents that are stored on a Sharepoint site. One of those documents (“receiving file”) contains formulas/cell references to the other seven documents (“source files”) on Sharepoint.
Everything works when the references are created.
Once the workbooks are saved and closed and then reopened, the receiving file no longer updates the values from the source files.
The files are synced in Windows Explorer and opened in the desktop version of Excel. Also, all eight files are opened at the same time.
The reference will first look something like this
='[Source file.xlsx]Sheet1'!$A$1
After closing and reopening, the references will look like this
='https://somecompanyname.sharepoint.com/sites/SitefortestingExcelreferences/Shared Documents/[Source file.xlsx]Sheet1'!$A$1
If I now change a value in the source value, the change will not appear in the receiving file.
What I tried so far
Setting “Calculation” to “Automatic.
Click “Calculate Now” and “Calculate Sheet”.
Double-click into the cell with the reference and hit enter.
In “Data > Queries & Connections” click “Refresh all”
In “Data > Queries & Connections > Edit Link” I clicked on update values. It did not help. However, I tried to rebuild a simple system with just two files and a single reference, and here it did work
Starting from point 5) I programmed a little macro that updates all links in all open workbooks (it did not help either):
Option Explicit
Sub UpdateAllConnections()
Dim wbWorkbook As Workbook
For Each wbWorkbook In Application.Workbooks
wbWorkbook.UpdateLink Name:=wbWorkbook.LinkSources, Type:=xlExcelLinks
Next wbWorkbook
MsgBox "Update complete.", vbInformation, "Complete"
End Sub
If I remove the path to SharePoint, so the formula looks like this
='[Source file.xlsx]Sheet1'!$A$1
It works again (until I save and reopen).
I found the following on Microsoft Answers (about OneDrive but it's probably the same issue):
https://answers.microsoft.com/en-us/msoffice/forum/all/excel-value-links-not-updating-on-onedrive/e48a7680-71e6-4a77-9eb1-e03ec7f0e3e0
I contacted the official O365 support desk and they told me this is built into the connection between Excel and OneDrive.
They have received thousands of complaints and there is no fix for it.
No option to tell Excel/Office/OneDrive to link to local copies of files on 1D by default.
No fix is planned as this is not how MS envisions how Excel/1D should be used.
My question
Any suggestions? Are there any tools in Excel that can be used to update the linked cells automatically or manually? Might SharePoint settings prevent the update?
If not, since removing the file path to SharePoint seems to work is there a way (using VBA) to remove the full file path from all cell references, so
='https://somecompanyname.sharepoint.com/sites/SitefortestingExcelreferences/Shared Documents/[Source file.xlsx]Sheet1'!$A$1
becomes
='[Source file.xlsx]Sheet1'!$A$1
I could probably loop through all cells and simply replace the path with nothing, but that would only work if I know the file path beforehand and if all the files are stored in the same SharePoint folder.
I had the same issue and here is my workaround: I can open the source file on the Sharepoint site by clicking ... and then Open in App (as opposed to Open in Browser) The referecence cell in the receiving file will become ='[Source file.xlsx]Sheet1'!$A$1 again and get automatically updated.
My workaround would be to consolidate external links onto a single sheet, and manually or use a macro to copy / hard paste to another identical page that you use for the links.
Just run the macro when you have the workbook open on your desktop to update the values.
Even simpler, you could also have a sort of database with linked values in a column and hard copies pasted into another column. This would be simpler than two identically sized sheets.
BUT, you could also go crazy and have named ranges like quarterly_total_formula and an analogue somewhere else called quarterly_total_valueonly and then write a macro to iterate over each with a for each looking for things "LIKE" *_formula and hard paste each result into the complementary *_valueonly spot... but then you'd need a macro to check that they were all paired... and by that point you might as well not waste your time in Excel and develop in Power BI, Tableau, RMarkdown, or heck learn Adobe Illustrator or work directly in HTML.

Excel "Forgets" revised linked values

My question is about issues with linked formulae in Excel spreadsheets.
I have a complicated structure of linked Excel Spreadsheets updated each month for Financial reporting.
The problem I have is that I will often update the values in source files. The links feed through correctly. Then I save all the files with the updated values in source and target files.
The problem arises when I reopen the files at a later time Excel forgets the revised figures. Then I need to go back and open the source files to make it pick up the new values again.
This problem is getting worse and worse, happening more and more for no apparent reason.I seem to spend half my time re-opening source files to update the linked values.
It seems like the Internal Table that Excel keeps for links is remembering old values and not saving the new one ones when I update the table.
So my question is this - how do I stop Excel doing this, how do I force it to remember the new linked values when they change in the source sheet and stop it from reverting to previous remembered values ?
To be clear, every time I do this I save everything in sight, but it makes no difference.
I have also tried to relinking to a different copy of a file and then linking back. This works sometimes, but not always.
If you're not getting this warning every time you open the 'target' workbook:
...then there's a good chance the problem is that, at some point, automatic update of external links was disabled.
To re-enable it:
On the Data tab, in the Connections group, click Edit Links
Click the Startup Prompt button
Choose the 1st or 3rd option.
Close & save all open workbooks and try it again.
If you chose the third option in step 3, all links should update automatically.
If you chose the first option in step 3, you will be asked if you want to update the links.
More Information:
Office.com : Control when external references (links) are updated

Excel will not update links, entire day of research and tests with random results

Short version, my Excel is set properly to automatically update links and all my files(locally stored) work fine for years. Suddenly one will not update linked data. I click on Connections>Edit connections>Check Status every linked file has "Warning! Values referring to other workbooks were not updated"
Refresh/calculate all does nothing.Changing to manual and doing this, back to auto, open and closing, restarting, using these same files on another PC. Nothing I did fixes it.
Clicking into an individual cell(F2) then back out though updates that one cell.
Open
All security settings are correct I am 98% sure, regardless whatever settings I had haven't changed and it did work.
I read a post that seemed exactly the same but his solution was enable protected content. Not the case here, i disabled it fully. There seems to be an error causing this possibly..
Long version. This is my largest file I continue to build
I have a main excel sheet that is linked to 35 workbooks. The source workbooks have lists of 3-4 columns, ranging from 1,000-10,000 rows long. The main WB uses index match for each source to pull two small fields. It takes about 5-6mins to do a calculate all with a desktop i7 3.64ghz ivy with 16gb ram.I never have issues on. Win 10/64bit and office 2016 64bit.
Some source files are .xls, I am in the process of changing them to xlsx but when I open the xls file and the values update. I then save as xlsx with a shorter name as well (trying to lighten the formulas) I go back to Connections>Edit connections>Check Status and the same warning is there. However I can click update values and it says OK.
This is very important file and is not physically monitored. Until something sells wrong I realize it wasnt updated, I am hoping for a concrete answer I can solve instead of just changing random things and hoping.. all help is greatly appreciated!
I actually resolved this by opening all source workbooks with the main workbook open and resaving them one by one (Status on some turned OK, most remained). Then I simply used Edit Links and Update Values for each connection which changed the status to OK. Saved the main workbook and no more issues..
Yes I need to take those suggestions and the workbook to the next level as it has clearly outgrown my skillset, but getting there..

can you delete a macro when a file is copied but preserve it in the original?

I have a workbook called Expenses Sheet.xls located in R:\LGS\FINANCES\. Lots of people refer to it and often save a copy so they can manipulate the data. There is an autosave macro in the original file, saving to a fixed location. Is it possible to delete all macros in the new (save As) copy, so the new copy does not have the macros contained in the original expenses Sheet.xls? This would stop all and sundries' copies being saved in my backup file as is currently happening.
First of all, theres nothing in your Excel file that executes when the file is being copied. At most, you'd be able to hook into an event which disabled or removed the macros when people saved the document somewhere else, from inside Excel, using the "File->Save As..." menu item, but if they drag and drop the file using Windows Explorer, you're out of luck in that regard.
However, have you thought about simply making all those macros check if this is actually the document that is supposed to be saved in that place?
Like this (note, I'm altogether unfamiliar with Excel macro syntax at this point so this will probably be wrong, but you should get the idea):
IF NOT DocumentLocation = "R:\LGS\FINANCES\ThisSpreadsheet.XLS" Then
Exit Sub
END
This way, the macros are still there, and will still execute, but they will essentially do nothing for everyone else.
Would that be an acceptable solution for your case?
Lasse V. Karlsen's suggestion is spot on, the exact syntax could be
If Not Left(ThisWorkbook.Path,16) = "R:\LGS\FINANCES\" Then
Exit Sub
End If

Resources