Sporadic shifted formula references - excel

I have an Excel file with multiple sheets that are for the most part protected. The user can only edit certain cells and all adding/copying/duplicating/deleting of rows is handled via buttons and VBA.
The code for inserting a row:
ActiveCell.EntireRow.Copy
ActiveCell.EntireRow.OffSet(1).Insert xlShiftDown
and deleting a row:
Selection.EntireRow.Select
Selection.Delete xlShiftUp
There's a large number of Sum(...) and other formulas in the Excel file. In general, those update correctly. Sum(B5:B10) correctly references Sum(B5:B15) when you add 5 rows to it.
Every now and then there seems to be a bug that corrupts a lot of the formulas and shifts them incorrectly (e.g. Sum(B4:B14)).
This happens occasionally and on specific PCs. I can't reproduce them on any of my machines.
On most of the User-PCs it works. On some machines it seems to appear more regularly, but still not reproducable on demand.
Most users report that it happens after they click the insert-row & delete-row buttons often in a short time.
Information from one user who encountered this problem:
Operating-System: Windows 10, 64-bit;
Excel-Version: Excel 2016, 32-bit
Excel had been opened from mail and was then saved on Disk.
Programs open at the same time problem occurred:
One other Excel file (without macros), Outlook, IE, Adobe, Skype
As far as I know there are no "automatic tools" like AutoHotKey or something along the lines installed.

Related

Renaming worksheet gives 'Out of Memory'; CurrentRegion property fails

My employer has recently upgraded from
Excel 2013 (15.0.4805.1001)
MSO (15.0.4919.1002) 32-bit to Excel for Office 365 MSO (16.0.11328.20362) 32-bit
There are no active add-ins (other than referred to below when loaded).
An Excel add-in (xlam) that I have created no longer functions correctly.
The add-in works with an open workbook and formats a lot of 'raw' data as tables (listobjects) and creates a number of PivotTables and Charts in a dashboard-style layout. During the process some blank sheets are copied from the add-in to the open workbook, and renamed as required.
For the most part, everything works fine (pivots created, dashboard created). At the end of the process I create an index sheet by copying a blank sheet from the add-in, and re-naming it (as ...Index). This is where things go wrong. Excel just seemed to 'hang'. On investigation I discovered that the sheet was not being renamed (so further processing stopped).
Delving into this further with error-trapping turned off, if I try to rename the sheet using the immediate window, I get
run-time error 7 Out of Memory
Further, if I manually rename the sheet (Excel interface) and then set the code running from that point, I've discovered that I can't use the CurrentRegion property (some sorting is done on the newly inserted sheet). Any attempt to use CurrentRegion results in
Unable to get the CurrentRegion property of the Range Class
This also applies to using the immediate window on ANY open workbook (e.g. ?Activesheet.range("A1").CurrentRegion.Rows.Count)
These errors persist during the current session of Excel (that is, I can create a blank workbook and try to rename a sheet using VBA but get an error; manually renaming a tab is OK). If I restart Excel everything is fine.
I require to use some global/public variables but (given that everything worked in Excel 2013) can't see that these would be the problem.
Any ideas?
After a further couple of hours looking into this, I established that the error was related in some way to a module which added slicers to the dashboard. The slicers were, in fact added (and stepping through the code no errors were generated).
Adding the slicers in a slightly different fashion appears to have got around the problem, although I am still none the wiser as to why it actually occurred in the first place (the original code for the slicers worked fine in Excel 2013).

Excel is unfilling calculated cells at random

I have an Excel file on SharePoint.
Multiple people edit said file.
Offline and online.
Excel unfills all calculated cells (VLOOKUP and MATCH) that depend on other sheets in the same workbook at random.
So if you would open or reload that file, suddenly all the cells that use VLOOKUP or MATCH would be blank.
Upon further investigation nobody changed anything or deleted anything.
It just happens randomly.
Now it has happened 2 weeks ago and just today.
I have an interim solution that is to go to a cell with a formula, hit return, then click „overwrite all cells in this column with this formula“ and then click undo to prevent custom cell content to be overwritten.
Everything is back to normal afterwards.
I talked to a colleague, he has the exact same issue also totally at random.
He also encountered this on files that are not being edited by multiple people but himself.
So it is not dependent on the file itself.
Could the language play into this problem?
On some PCs Excel is in English and on some in German.
=IFERROR(IF(ISNA(VLOOKUP(D185,Sheet1!$B$3:$D$616,3,FALSE)),(VLOOKUP(D185,'Sheet2'!$B$3:$D$22200,3,FALSE)),(VLOOKUP(D185,Sheet1!$B$3:$D$616,3,FALSE))),"")
Seems like your sheet isn't calculating upon open. See if this link is of use to you.
https://superuser.com/questions/448376/what-is-the-excel-hotkey-to-re-calculate-all-formula-in-sheet
Also check your program settings and see if auto-calculate sheets is enabled. Don't know from the top of my head where it is located.
Alternative create a small vba function to force recalculate on workbook open.
Getting Excel to refresh data on sheet from within VBA

My macro makes the file size larger although it deletes information

I am using a macro to create individual reports for different stakeholders in the company. The problem is that the files saved by the macro are larger than the parent files.
Please mind:
There are no "Empty lines" taking up space.
There are no connections to external sources in the outcome files.
There is no macro in any file (original or outcome).
I did see a very similar post from a couple of years ago but this had no satisfying answer. Although someone hinted at the command used to save, this is the one I use :
ActiveWorkbook.SaveAs Filename:="C:\path\" & WR_Date & "Monthly-Report" & Partner & ".xlsx "
(Excel Macros file size)
Below is a recap of the steps done by the macro.
Macro opens "Master workbook"
Deletes all external connections (OLAP)
Deletes calculations in the tables (copy as simple values)
Deletes reconciliation table sheets
Saves 4 files (Division master, Country master, Territory master, Partner master).
Uses these master files to delete all irrelevant data for the stakeholder.
Update all pivot caches (settings of all pivotes to not keep memory anyway.
Protects all worksheets and the workbook.
Saves the files with the correct names.
As per the discussion in below comments, I am pasting my macro below. The replace all function was used to remove any kind of sensitive information, sometimes the result may be weirs but it should definitely be enough to spot the issue.
I am pretty sure that the macro is causing this: if I replicate the steps done by the macro the size of the files is much smaller (5-15 Mo vs 50-60 Mo).
Also, the territory reports are normal sized. The country and division files are bigger than their master file, the partner files are also too big.
EDIT:
After plenty of checks, I have found the begining of an answer, it seems to be related to the way the pivot tables are refreshed. My code was going like this:
ActiveWorkbook.RefreshAll
For Each pc In ActiveWorkbook.PivotCaches
pc.Refresh
Next pc
I have now removed the "Refresh all" prior to refreshing the pivot cache and save about 20 Mo per Division and Country file. This is still not entirely satisfactory since the division and country files still are around the same size as their parent or bigger but these reports need to be posted today.
I'll keep on looking but will definitely try to poste you a full resolution by next month!
Ran a quick test and it may be related to the data in the file being corrupted.
"TestSize1" files are only containing data values
"TestSize2" files are only containing of excel functions
"TestSize3" files are only containing of formatting
Windows File Explorer - Test
I am only seeing a minor increase in file size on the "Values only" or "TestSize1" workbook. I do believe you shouldn't see a size increase unless the data in the workbook is corrupted for your case. This file type just permits the additional save of features, such as Macros/VBA code.
"The first is the default XLSX, then there's XLSM which is identical to XLSX except it can contain macros..."
I would look into copying just the data values out into a New workbook and save that as .xlsb. It should reduce the size (obviously), but also it removes features that excel maybe misreading or corrupted. After that open the .xlsb in a restarted window of excel (maybe restart your computer before as well to clear cache) and attempt saving back to whatever format you prefer. Add function and formatting to restore the document.
This has worked for me, off and on, for recovering large .csv files. I hope it works for you.

Why is Excel temporarily locking us out of non-locked sheets/cells?

I am having trouble diagnosing this problem we in our office have begun to experience since... upgrading(???)... to Excel 2016.
We cannot recreate the issue on command; we are not sure what causes it. I am not even sure what to Google (list below)! We'll be working in a sheet, all is normal, moving from cell to cell or whatever... then at some point, moving from one typical cell to the next, suddenly, the sheet just... stops letting us use it. It just stops letting us make changes and acts strange.
Here are the symptoms:
Can edit some cells, but the changes will "vanish" when you leave the cell.
Can not click on all cells. The selector with just not highlight them.
Can not add or remove filters, or sort.
Can not Copy or Paste.
Can not delete any cells that can be highlighted.
This can happen to us on a variety of sheets and none of them have "protection" or sheet locking of any kind whatsoever. Zero, zilch, nada. These sheets are NOT "Locked for Editing". And I've looked at my co-workers keyboards to ensure that something silly like Num or Scroll lock wasn't causing the problem; they're not enabled.
One solution which I've found sometimes seems to fix the problem, is to switch sheets. That's it! Sheet1 not responding and treating you like you're locked out? Switch to Sheet2 (just click on it) then switch back to Sheet1. Fixed! Now the cells just... work again. The selector works again. Editing works again, just from switching from one sheet back to another. Well... sometimes.
Other times that does nothing, and then we have to save and reopen the sheet, and it works fine without any other changes. It is very confusing that, without even doing anything besides reopening it, that it works again.
These are a few examples of the stuff I've tried Googling over the last few weeks (I don't think I need to provide the complete list here... all searches have returned nothing useful, only articles talking about how to Lock and Unlock your sheet properly, which isn't this):
excel 2016 locks from editing
excel 2016 locks while working
excel 2016 locked for editing not locked
excel 2016 can't edit until switch sheets
I believe this is a known problem in excel 2016, Especially if you have windows 10. It looks like you need to keep resetting it like you have been doing but it is annoying.
If you try to disable "hardware graphics acceleration" in options menu, that should fix the issue and you would not have to keep switching between sheets.

MS Excel 2013 linked data formula reverts to value #REF despite linked values not changing

I am currently working on an MS Excel 2013 spreadsheet (p:\master.xlsx) where some cells contain values that are directly linked from other MS Excel 2013 spreadsheets (p:\path1\feeder1.xlsx, p:\path1\feeder2.xlsx, etc).
What I am finding occasionally (not every time), is when I open up my p:\master.xlsx spreadsheet (and then "enable editing" and "enable content"), some of the values in this spreadsheet change from the correct linked value (a number) to value #REF.
When I look at the formula within these offending cells, I see it has also changed from say:
=MAX('P:\path1\[feeder1.xlsx]Sheet1'!$C:$C)
to
=MAX('P:\path1\[feeder1.xlsx]#REF'!$C:$C)
I can confirm the feeder.xlsx spreadsheet has not been moved or renamed and has not had it's values changed at all. The network drive the files sit on is also stable.
What is confusing me is that this appears to happen at random times (as opposed to every time). In addition, not all the cells revert to #REF - some of the values are still OK (and thus the formula is OK).
Due to not knowing if or when the formulas will change to their "#REF" status, I need to save the file every time I make a change (slightly frustrating).
I searched the forum and noticed another user had a similar issue on MS Excel 2010 but the answers provided did not appear to solve the user's issue. Anyone have any suggestions?
First make sure you're formula is not too long if your using 97-2003. if so save the file as .xlsx
if that don't work do the following
close all open workbooks.
open the workbook with the (now) broken links (#ref).
Click on the Data tab
Click on Edit Links.
Excel doesn't like links to closed workbooks

Resources