Force Excel to keep sheet name when referencing external tables - excel

Is there a way to force excel from automatically "rewriting" the address of the external reference?
Example
When I mouse over and select a table in another workbook as a source, the formula bar shows this:
=[WorbookName.xlsx]SheetName!TblName
Once I hit enter, the formula bar shows this:
=WorbookName.xlsx!TblName [#Data]
Brackets and sheet names get removed and [#Data] gets added.
I confirmed that excel understands the address with the sheet name by using indirect and forcing excel to use the full reference
=INDIRECT([WorbookName.xlsx]SheetName!TblName)
So its not a limitation by excel. However this only proved that excel can handle that style of reference. The problem is that when you use indirect, youre not actually creating a "link" to the source file, your workbook will never ask to update the values if the source file is closed.
I need to force excel to keep the table name in the reference because I will be uploading to OneDrive and co-authoring the workbook. When you reference a table in another workbook, and that workbook is closed, the reference is changed to include the web address of your OneDrive like this
source file open: =WorbookName.xlsx!TblName [#Data]
source file closed: =https://d.docs.live.net/location/FileName.xlsx'!TableName
I believe this is causing errors, preventing excel from updating the values. when I first open the workbook that contains the links, it will try to update to the latest data. When I use regular ranges, it has no issues. When I use tables, I get "we cant update some of the links in your workbook right now". If you go to edit the links, it looks like this:
Edit Link
If you try to update the values, you are shown this, Notice it is looking for a worksheet but the name its expecting is actually the name of the workbook.
Select Sheet
I believe this is because when you reference a range, the address is written like this:
Rance referance =https ://d.docs.live.net/Loacation/[FileName.xlsx]SheetName!$A$1:$D$20
table referance =https ://d.docs.live.net/location/FileName.xlsx'!TableName
Notice there is a difference in the location of exclamation ! point. I believe this is the reason why excel shows the workbook name as the worksheet is looking for. again if you use indirect, youre able to force excel to use the "long" address, so we know excel recognizes it with no issues.
Really hoping to find a solution, thanks in advance!

This is an alternative to what you're trying to do.
I did some tests and if the file is saved in OneDrive, you could have it open (from OneDrive not locally) and just refresh the data with PowerQuery.
Steps to create the query:
In Chrome:
Locate the source file in Onedrive (aka: https://onedrive.live.com/)
In google Chrome, download the file (we need to get the download link in the next step)
Click the elipsis in Chrome's top right corner and click on Downloads (or press Ctrl + J)
Right click the link of the downloaded file, and select Copy
In Excel...
Click Data | Get Data | From other sources | From web (I don't have the english version right now, but you should be able to locate it)
Paste the URL
Click Ok
Select the Sheet/Table (do any transformation you may require)
Click Close and Load to...
Select a sheet or any location
Press Ok
Now do any formulation against that table
As said, I did some tests with the file opened in another instance and then refreshing the table, and it worked.
Let me know if yours do.
EDIT:
As per your comments, (though I didn't test it) I did some research on how to make this work with the default sharing links.
Here are the steps:
In Chrome:
Locate and select the source file in Onedrive (aka: https://onedrive.live.com/)
Click on Share and generate the view/edit link
Copy that link
As of this date, the link should look something like this:
https://1drv.ms/x/s!ArAKssDW3T7wnIIEvmhHrMxfvhowww?e=UsaATm
The key here is to replace the ms with ws, so the link that you need to use in Excel should be something like this:
https://1drv.ws/x/s!ArAKssDW3T7wnIIEvmhHrMxfvhowww?e=UsaATm
In Excel:
Click Data | Get Data | From other sources | From web (I don't have the english version right now, but you should be able to locate it)
Paste the URL
Click OK
Righ click the icon that says 1dr.ws
Select and click Excel
Continue with the other transformations

Related

"This workbook contains external data. Do you want Microsoft Excel to clear the data before saving" prompt

I have created a macro-enabled template, which contains only a empty dataset sheet sourced to a number of pivot tables.
Every time I try to save the template proper, or even a new workbook based on the template, I get the error:
This workbook contains external data. Do you want Microsoft Excel to clear the data before saving the template, and then automatically refresh the data whenever the template is opened?
There are no connections in data>connections>connections.
Edit Links is grayed-out in data>connections.
I have downloaded and ran "https://www.manville.org.uk/software/findlink.htm" with no links found.
The only item in formulas>name manager the dataset table with no external link.
I have unchecked file>options>advanced>ask to update automatic links.
I have enabled all items in file>options>trust center>external content.
I can't find anything in my VBA code that would cause an error like this.
This error prompt haunts me. Why is it doing this?
Thanks for any answers.
You most likely have a formula in a cell or a define name that points to an external file. Do a search for "HTTP" in your workbook and review your define name.
As it turns out, it's just a source template thing. Once I open a new document from the template, that warning doesn't come up.

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.

creating dynamic hyperlinks when importing data into excel

I am trying to automate a process where data is queried from the database, downloaded into an excel file and sent to recipients. One of the column in the excel file needs to be a hyperlink. How can i make this happen?
I selected =hyperlink(A,B) into the column but the function appears as text and not as hyperlink.
I tried changing the web options to 'update links on save' but it does not help.
Only when i click in the cell and hit enter does the hyperlink appear. This is not an option
Opening the file and adding a new column to use the hyperlink function is not an option either since the process is being automated.
The tool allows me to export into an xlsx and not a xlsm so i am assuming i cannot use macros to do the job.
I tried researching the answers for similar questions but didnt find any that i could use which will generate a url dynamically without me having to open the file. Any ideas?
I also tried another tool and they were able to send out emails with links. I do not know how they do it internally but i do not see any hyperlink functions when i tab into the hyperlink column.
Cell type should probably be set to "Generic".
You may also need to trigger a "Refresh" after the workbook is filled with all the data. Sometimes I need to that manually - but only once. I have no idea why it happens.

Formula information displaying correctly, but link information is not

In the picture above I have placed the following formula in cell J1:
=HYPERLINK(LEFT(CELL("filename",A1),FIND("[",CELL("filename",A1))-1),LEFT(CELL("filename",A1),FIND("[",CELL("filename",A1))-1))
I originally created the file on my local C: drive and personal download folder. I then created hyper link formulas in I4, and copied down, that build on the path name J1. This worked fine and dandy when I tested it.
PROBLEM
When I move the file to the network drive, the value in cell J1 showed the new new network path. However when I click on the link it would open my personal download folder where I originally created and saved the workbook.
What I have tried
I thought there might be some value saved some where that was not updated when I moved the file since I used explorer to move the file as opposed to saving the open workbook in a new location. To over come that I tried saving the file in its new location with no effect. I also tried save as with no effect either.
What I was trying to achieve
I was trying to achieve an automatic link that would allow the user to click on the drawing link and it would open the associated file independent of how they have mapped or reference the network location. It would also automatically update the path should the folder be moved or renamed.
What went wrong? is there a better way of doing this?
Potential Cause
When using the =HYPERLINK formula, excel also generates a hyperlink as if you added one manually by right clicking on the cell. It then also formats the text with an underline and blue/purple text. This "manually" created hyperlink sits on top of the formula so it gets selected first. It is this "manual" hyperlink that does not update.
Work Around
Select all cells with the issue. Right click to bring up the menu and then select remove hyperlink. This removes excels "Manual" hyperlink, but leaves the cells hyperlink formula which still works and is updated.

How can I use a data connection from another book?

Under Data -> Conections I have added a link to another excel worksheet. I'm trying to use some value from this new linked worksheet but I dont know how.
I'm researching this, because using [file] or indirect() is not enough.
How could I reference a cell from a defined data connection from another worksheet in a linked excel file?
I fear that even a highly simplified answer to your question may require pages and pages of detail (for example, not counting the Connections icon set in the Ribbon, for Get External Data I have five icons in the standard Ribbon to choose from and one of these offers me seven choices) so merely an example:
In a new workbook, enter 666666 in Sheet2 B2, select B1:B2 and INSERT > Tables, Table, check My table has headers and OK. Save this workbook as WB1.xlsx, somewhere you can relocate it, and close it.
Open a new workbook and select A2 in Sheet1. DATA > Get External Data, Existing Connections. Browse for More…, find and select WB1.xlsx. Open. A Select Table window should then pop up and from it Select Sheet2$. OK. OK. In A3 of this new workbook you should now see 666666.

Resources