Excel - Change source of chart data depending on text in cell - excel

I have one excel file in which I have multiple sheets with financial statements from different companies (called Databas.xlsx). The structures of these sheets are identical. Then I have another excel file that I wish to use to analyse these financial statements using charts. Thus, I must get data from the different sheets into my analysis file. Doing this from one sheet is no problem, as I can simply create a chart and mark the data I need from this sheet, so that the chart data range would be something like this:
=[Databas.xlsx]Kopparbergs!$C$3:$K$3
where "Kopparbergs" is the sheet name in Databas.xlsx. The problem I am facing is that I want to be able to change the sheet name that is put into this formula by writing the name in a cell (because that would enable me to change multiple charts at once). So just to clarify, in the formula written above, I want to be able to change the word "Kopparbergs" by writing text in a cell. If that is not possible, how would I accomplish this? That is, how do you create a chart that can change its content depending on a text in a cell that corresponds to a sheet?

So rather than using Indirect I think you need to use two named ranges for referencing when using a Chart.
This previous answer looks like a good guide to implement (not sure about etiquette of just copy & pasting previous answers so I'll just provide the link):
Dynamic chart range using INDIRECT: That function is not valid (despite range highlighted)

Related

Excel chart adapting to table with formula-generated rows -- without named ranges?

I have table-like data, and I'm looking to make a chart that displays that data. Since the data is that formula-generated from other data in the workbook, I don't know in advance how many lines it will have. I want to make a chart that adapts to this data.
Up to this part of the question, I could use named ranges to solve this.
The thing with the solution with named ranges is that it does not scale well when I have many of these charts. I have a Python script that generates CSV files that I import into my workbook as a sheet, and I don't want to have to know in advance how many of them there will be, or what they will be named. I only want to be able to import the CSV files into a new or existing sheet, and copy-paste the formulas from another working sheet, as well as be able to replace the existing CSV data with new data.
With named ranges, I would have to manually create a named range for each series of each sheet, and I would have to use the sheet's name so that the named range can be visible to the whole workbook (in order to analyze the data in a global sheet) without any name conflict. This is (more or less) acceptable when I do these steps myself now, but if I want to redo this in a few months, or if I pass my workbook to someone else, we wouldn't know why it's not working with a new sheet.
So is there any way to get this done without delving into VBA stuff? I'm using a recent version of Excel.
Per the comments, try using pivot tables, making your range extend far beyond expected results and filtering out "blanks" in your pivot and generate your chart from that. The default pivot chart is ugly but you can remove buttons and format as needed. Just remember to refresh your pivot during every update period.

Reference another Excel Worksheet via a Keyword

I am not sure if this is too ambitious. Currently I'm generating a bunch of pivot tables through our server (I won't go into detail) but our main stocktaking spreadsheet references these generated pivot tables weekly and pulls their figures through.
i.e using code ='C:\Users\ITS1\Documents\Test\Establishment\190303[Stocktake.xlsx]Data4'!$D$3 which is simple enough - just referencing whatever figure is in that cell on the pivot table.
There is a particular bunch of figures on some pivot tables each week called 'Redemption' which, depending on what other kind of sales an establishment generates, shift to different cells each week. So I can't reference them like other figures which are always fixed to the same cells on every generated pivot table.
Is there a way I can reference the pivot table by the keyword 'Redemption' and take the figure from the cell directly next to it which is the actual figure we need to record?
While this isn't hugely urgent, it would be quite handy. These figures can just be manually entered but just trying out some automation to eliminate my human error :)
If you don't want to have to open the external workbook, this approach might be feasible:
In the external workbook, create a helper sheet that uses a formula to look up the Redemption field value. This could possibly be done with a GetPivotData formula. The exact formula depends on your data and without seeing that I can't write it.
The idea here is that the helper sheet and the location of the cell on the helper sheet does not change. When the pivot table is refreshed, the formula calculates the result.
In the other workbook you can now use an absolute reference to that helper sheet and cell and don't need to open the external file to retrieve the value.

Dynamically specify worksheet without indirect() in Excel

In my database, I have created separate worksheets for different sources of data, to make the database more structured for the users. In the summary page I created, I would like to dynamically refer to these worksheets, to easily visualize the data.
The "sheet selection" looks as follows.
Site should determine from which sheet the data comes. Afdeling and Data are columns in these sheets, and its values are used to find the data range (row start and row stop).
In this excellent question and answer, it is explained how to dynamically refer to a specific data range by Function, without the use of Indirect() (Why I don't want indirect). However, it does not answer how to refer to a sheet.
Is it possible to select the worksheet in an excel file by function, without using Indirect()?

How to pattern graphs on excel

I wanted to ask how it is possible to pattern graphs on the same sheet in excel. I am aware already that one can pattern the same graph with all its formulas by copying the whole sheet.
However I am looking for the pattern-action inside the same sheet, as it would result as very useful for me.
That means that I do once the whole work, along some given rows, which includes some graphs.
This whole content shall then be repeatedly copied down the columns, with the condition that the new graphs are locked on to the new destinations... Not the old ones.
Thanks for all input.
The series formulas for a chart contain absolute references and they cannot be changed to relative references. That means that when a chart is copied and pasted into the same worksheet, it will still refer to the original data range. The exception, as you noted, is copying the whole sheet, which will lead to the references being adjusted to the new sheet name.
When you copy a chart and paste it into the same sheet, then you need to adjust the references, either manually or with VBA.

How to build a chart in excel, such that the source file containing data can be changed interactively?

I have a directory with many excel files with numeric data. In each file the data is arranged in the same manner (the same column names, etc...). I am interested to build an interactive
chart which will display the data according to the chosen file name.
For example, the file name will be chosen from validation list in a drop down menu fashion.
The question is how to specify the data range in the chart, such that it will change according to the name of the file that I choose.
I work with excel 2010 and don't have much experience with VBA programming :(
Thanks a lot,
Sasha
Well, a simple solution (there may be more elegant ways but that's a first hint):
Copy the data from your files in the Sheets of your workbook, you can create references (see here) or automate copies through macros (just STFW)
Create your validation list (for instance on Sheet1, cell A1). Let's assume this list contains: DataSource1, DataSource2, DataSource3.
Create Named Range for every other Sheet you have and use the same name as the one in your list (DataSource1, DataSource2, DataSource3)
In the chart source of values, use this formula: =INDIRECT(Sheet1!$A$1)
Hence, Excel will translate the source to the Named Range.
You could probably find solutions with vba too depending on your needs.
Regards,

Resources