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.
Related
Let's say I want to copy Cell C5 from workbook 2 to workbook 1. The name of workbook 2 is a variable given in Cell D1 of workbook 1.
The problem with using Excel's built-in Indirect() function is that the value disappears when workbook 2 is closed. I'm hoping there's a simple VBA macro that can do this.
Thanks in advance.
You seem not to have a lot of experience in Excel VBA, let me give you the general approach for such an exercise:
You can record macros: go to the "Developers" tab, start recording, do the thing you want to do (the copying) and stop the recording. There should be a macro, describing what you have done.
Unfortunately, when doing this, the macro will be something like this:
Source_Range.Copy
Destination_Range.Paste
Generally it is advised to replace this by something like this:
Destination_Range.Value = Source_Range.Value
Good luck and if you have any more problems while doing this, you might ask again by editing your question (I'll be following this question).
The behaviour you're observing isn't a limitation of the INDIRECT() function, but a more general limitation of Excel functions only having access to other workbooks when they're open.
You can use another workbook as a data source by selecting Data > Get Data > From File > From Workbook from the ribbon. Select the source sheet from the Navigator pane, and select Load. This will open the PowerQuery editor.
PowerQuery is an advanced topic which I won't attempt to fully address here, but the default transformation should give you a table containing data from the source worksheet, without relying on that workbook being open in another instance of Excel.
I have a large file with a Scenario Manager, where changing a single cell on the Summary worksheet changes the visible scenario throughout the rest of the workbook. Data Tables are working a treat providing the headline values for each option.
I'd like to have a drop down on each sheet that when changed will change the same single cell on the Summary worksheet, so I don't need to go back to the Summary sheet every time I want to switch visible scenarios.
This is a simple process if I'm using macros and would be the solution I'd normally jump straight to. But this needs to be done without macros and this is where I'm now struggling.
Does anyone know if this is possible (without macros) and point me in the right direction?
Josh
You can insert combo box (Developer Tab > Insert > Form Controls > Combo Box) on each sheet. Mention linked cell as a cell of the summary sheet (Absolute reference with sheet name). That cell will give you index of the item selected in the drop down list. Then you can insert index formula in the cell you want to change every time to get value of the drop down list. Once you insert it on one sheet you can copy it to other sheets. No macros required.
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
I have been having problems with a pivot table that uses an external .csv file as its source, particularly with dates in the csv file being treated as text. So, I decided to import the csv file into another worksheet and then force the dates to be recognised as such by reformatting the relevant columns.
The problem I now have is changing the existing pivot table to use the data in the new worksheet instead of an external source. If I click on "Change Data Source" button, the "Select a table or range" option is greyed out. If I continue with external data source and click the Choose Connection button and select the new worksheet I get a pop up that says "The type of connection selected cannot be used to create a PivotTable".
I also tried converting the csv file to xlsx but had a similar problem trying to get the existing pivot table to use it instead of the csv as its source.
It's been a while since you asked, but I had this same problem and just discovered a solution.
Basically, you can use VBA to change pivot tables to a new pivot cache. If the new cache uses the same fields then your layout will be preserved.
Create a new pivot table based on the new data source (it can just be empty).
Click in the new pivot.
In the immediate window type "? selection.pivottable.cacheindex" and press enter.
Note the index number of the pivot cache.
In Excel click in the old pivot which you want to change.
In the immediate window type "selection.pivottable.cacheindex = x" where x is the index number you noted in step 4.
Repeat step 6 for every pivot table which you want to use the new source.
Remove the table you created in step 1.
There may to change all tables from one cache to another in a single step, but it's probably not something you need to do often.
Yes, that is an annoying constraint for pivot tables.
Steps to recreate the and change the datasource from .csv to .xls file:
Created a .csv file with headings Name, Birthdate, Sign. Closed the file.
Imported the .csv into a new pivot table PivotTable1 in a new workbook.
Saved the orignal .csv into a new workbook c:\path\to\datasource.xls, naming the worksheet Data and making sure the upper left cell of the data range was in cell A1.
Then I added the following VBA macro and executed it:
Sub getExcelData()
With ActiveSheet.PivotTables("PivotTable1").PivotCache
.Connection = Array( _
Array("ODBC;DSN=Excel Files;"), _
Array("DBQ=c:\path\to\datasource.xls;"), _
Array("DefaultDir=c:\path\to;DriverId=790;MaxBufferSize=2048;PageTimeout=5;") _
)
.CommandText = _
"SELECT `Data$`.Birthdate, `Data$`.Name, `Data$`.Sign" & vbCrLf & _
"FROM `c:\path\to\datasource.xls`.`Data$` `Data$`"
End With
End Sub
The .CommandText syntax for this driver is horribly picky and not at all smart.
YMMV with this code in 2010 or later and/or with different drivers. Date and numeric data are notoriously ill-handled even in later versions of Excel data drivers. I generally make sure that every cell in a numeric or date field has a valid value, or at the very least every cell in the first row of data, before importing.
This helps but for those who dont know where is immediate window you need to go to developer tab and get in the Visual basic Macro window and press Ctrl+G it will open the immediate window at the bottom. Original answered by mendosi It's been a while since you asked, but I had this same problem and just discovered a solution. Basically, you can use VBA to change pivot tables to a new pivot cache. If the new cache uses the same fields then your layout will be preserved.
Create a new pivot table based on the new data source (it can just be empty).
Click in the new pivot.
In the immediate window type "? selection.pivottable.cacheindex" and press enter.
Note the index number of the pivot cache.
In Excel click in the old pivot which you want to change.
In the immediate window type "selection.pivottable.cacheindex = x" where x is the index number you noted in step 4.
Repeat step 6 for every pivot table which you want to use the new source.
Remove the table you created in step 1.
There may to change all tables from one cache to another in a single step, but it's probably not something you need to do often.
Since I'm a new member, I can't add comment nor add vote.
Anyway as I found this page because I have the same problem,
to me, the answer from Ines is correct and the easiest one.
Excel 2010:
Customize The Ribbon....
Commands not in the Ribbon...
PivotTable and PivotChart Wizard...
Add number-3 as new menu (I choose as new menu in the INSERT tab)
Click the Pivot Table which data source need to be changed from external connection to a range or table in the active worksheet.
Click number-3 menu
Click "back" twice
Choose Microsoft Excel List or Database radio button
click "next" then fill the range or the named range in the range-box
Click FINISH
There I can finally change it from external data to a range
Thank you very much, Ines.
(Don't know why someone down voted you).
Alright I know this isn't 100% related to programming (the Excel book in question doesn't use VBA at all) but I'm hoping someone can help me out with this or point me in the right direction.
My boss got a spreadsheet from a vendor that has a combobox/dropdown list with various part numbers; when you select one it populates the rest of the form with a lookup containing additional items. I've been tasked with "cracking" this and finding the list that they're using to populate so we can make use of it.
The thing is... there's no VBA code, no macros, no data connections, and only one Worksheet displayed in Excel while the lookup code references a Sheet1. I've tried to display hidden worksheets and it says there are none... so where on earth could this list be kept? My boss is getting impatient and is asking me if I've broken it yet. It's not a big deal if it can't be done, I just have no clue where to continue looking for it and I don't know what to tell my boss when he asks me if I'm done.
Can anyone help?
It's possible to hide a worksheet using VBA so that it can't be unhidden from the UI.
Try the method for un-hiding all hidden workhseets outlined here:
http://www.automateexcel.com/2004/12/14/excel_vba_unhide_all_worksheets/
My guess is that it is a Data Validation list which references a constant list of values or a range on a "Very Hidden" sheet. In Excel 2007, select one of the cells with the drop-down, click on the "Data" tab in the Ribbon, click on "Data Validation" in the Ribbon and see what you have. In Excel 2003 it is the Data -> Validation... command.
Another possibility if you know the name of the worksheet is "Sheet1" is to add a new worksheet, enter "=Sheet1!A1" into cell A1 of the new worksheet, and copy this cell down and to the right for as large of an area as you need to see the data you are interested in.
If you can post a URL to download the workbook (assuming it is not a trade secret) you would be more likely to get an accurate answer.
Could it be some data stored on the same sheet.
Possibly in columns which are either hidden, or which are far off the actual page?
Isn't this just data from the worksheet only?
Column header dropdown lists acts as filters, they show distinct values of a column.
This is a feature of Excel.
The items could be cached from a currently unavailable resource. Try saving it out to xml and searching for a known string.
Click on the cell that display a drop down list when selected
From the menubar select data>validation
In the dialog box copy the content of the source text box
Now paste the content on any empty cell on your worksheet
Select a drag it down to see the values populating the list
Chris
------
Convert your Excel spreadsheet into an online calculator.
http://www.spreadsheetconverter.com
I am assuming that you have broken this by now, but just in case you havent. This is certainly a case of data validation using a named range which is house on another sheet that was designated "very Hidden" from the vba console. You will need to open up the VBA project of this worksheet and designated the "very Hidden" sheet to just Hidden and then you will be able to unhide it, or the other setting at which point it will be viewable.