dynamic linking of word and excel - excel

This is my first question and it would have been nice to include an image but it seems that I can't. I have seen some answers to my problem but they always seen to be in one direction. Excel->Word. However I want Word->Excel->Word as described below.
I have an excel workbook that draws a graph. Some of the input data is pre-calculated and one or two parameters are entered manually and entered in a table in the spreadsheet.
I want to do the following.
The graph and the data entry table are to be displayed in word. The table in Word is also part of the spreadsheet but must be displayed separately. I want to be able to enter the variables in the table in the word document. These values are linked to the excel sheet, the graph will be changed and the actualised version displayed in the word document. I have attached two images, the data entry able. The entry fields are those in green and an image of the resulting graph. Any help would be appreciated.

I can't see your pictures, so the following is theoretical.
1) Open Word
2) Insert Chart - this opens a instance of Excel which is directly linked to the Chart, which I'll refer to as ExcelChartData to avoid confusion.
3) Edit the range in ExcelChartData to match what you have in your Excel data workbook.
4) Link the ranges in ExcelChartData to the required ranges in your Excel data workbook.
Changing the values in your Excel data workbook will then change the chart.

Related

Select Data for excel Graph sees zeroes when I load the data using sql

I have a problem with Excel (2016)/ VBA macros. I am happy to provide more detail or copies of files if required.
In summary this is what is happening:
I have a workbook with five worksheets. Three contain data representing both axes of a matrix (1&2), the cells of the matrix (3), one sheet on which data from sheets 1 to 3 are brought together (4) and - finally - a graph worksheet (5 - based on a range in 4).
The reason I do it like this is that I want to graph parts of the data at a time otherwise it is all too confusing. A simple form is used to choose which column of the data-set to display and to also allow stepping through the list of items to display so just part of the range is in view at a time. Variables are set in cells on sheet 4 (outside the graphed range) when the buttons are clicked on the form. The formulae that populate the graphed range on that sheet use these variables to choose the required data from sheets 1 to 3.
Initially I populated the data in sheets 1 to 3 using macros to read from text files. These files had to be populated from a database before opening the Excel workbook. I decided to "Simplify" this process by changing the macros to query the database directly.
It took a while to get this going and all looked fine. I can see the data in the first four worksheets is populated correctly (including being able to click on the form buttons and change the contents of the graphing range) but the graph sees values of zero in every cell. When I right click on the graph and select "Select Data" and then choose an item in the "Legend Entries (Series)" list in the left-hand box, and the click "Edit", I see the cell ranges of both the Series name and the Series Values are correctly displayed, the preview of "Name" has the correct value but the preview of "Series" shows a string of comma-separated zeroes.
I can switch worksheets to view the "GraphData" on sheet 4 while still keeping the dialogue box open and see the actual cells that are being referred to and they are not 0, 0, 0... they are 78, 69, 44...
Where are the zeroes coming from?
I have even saved the workbook - keeping changes - so the contents of sheets 1 to 3 are kept, put a stop in the "Workbook_Open" macro so it doesn't run, and still I get zeroes when I re-open it.
Sorry to bother folk. I worked out the problem. As usual, there were interesting lessons along the way.
I started out with a query that populated a text file with data from my database. Because I wanted the file to be ingested by Excel as a csv file, the output for each row of the selected data was a single string column containing the keys and the data values with commas between them, the numbers being converted to VARCHAR within the sql so I could concatenate them into the string.
Them when I decided to try using the query directly from Excel rather than having the file step in between, I removed the concatenation operators and the commas and put a comma between them in the sql syntax but didn't remove the conversion to VARCHAR of the numbers.
With QueryTable, when you import a text file, one of the optional properties is an array of codes representing the data types of the incoming data. I assumed that with a direct query, Excel would assign a data type based on content as it does for typed values (unless you specify another). Clearly Excel and the source database exchange information, in addition to the data set itself, that tells Excel the data type of the columns - as sent.
The graphing function was seeing my data as strings so assigned values of zero. I began by putting a Value() around my lookup functions on the GraphData worksheet. That worked but then I went further back and actually changed the Sql so it sent numeric data without conversion to VARCHAR and then it worked without the Value() change.
It never occurred to me that Excel wouldn't just see a number and treat it as such - not that Sql Server would have told Excel it was a string.

VBA Help to Copy Worksheet from Excel into Word

I am creating a service contract for a client. The document has an Appendix that is a table that changes depending on the product. All of the Appendix tables are in Excel, and I have created an INDEX MATCH function to return the name of a Named Range according to the product chosen, and now I need Excel to actually display that range.
This is my function:
=INDEX(References,MATCH(A2,Reference!A2:A30,0),MATCH(B2,Reference!B1:D1,0))
It returns a Named Range because that's the data I have in the table:
"References", but I want it to display the table and not just its name.
My ultimate goal is to have Word display the correct table depending on choices selected in form fields within the contract. Basically, I want to automate copying the correct table from Excel into Word. It needs to keep its original formatting. Pasting as an object or image is acceptable.

Programmatically add rows to an Excel data model via C#

We're looking at allowing our customers to download an Excel file from our web application which contains a raw export of their data along with some basic charts and pivot tables based on that data.
The basic way, we want to make this work is that we have a fixed Excel file which contains all the reporting elements in one worksheet and have room for the underlying data in another worksheet. When the user requests their Excel report, we programmatically fill out the data worksheet with their results and send them the final Excel file.
Everything seemed a bit to easy when doing the prototyping with a fixed set of data. The dataset we worked with was added to the Excel Data Model and we then set up the charts and other reporting elements. However, when using that file as the template for the generated Excel file in our application we are finding that the definition of the data model still remains - meaning, that we built the "protype" with a table definition of $A$1:$T$5879
but when generating the report, that definition isn't changed to contain whatever size the added dataset might have.
We're using EPPlus to work with the generation of our Excel sheets and have so far been unable to find any sort of solution to this kind of problem. This might very much be due to us being quite Excel novices. The goal is to have the user experience, that the charts and pivot tables contained in the Excel sheet reflects the total dataset contained in the Excel file without them having to do anything.
Ok, I've actually found a solution for it.
The solution was right infront of us.
We define the dataset as a named set - this is done under under the "Formulas" and inside the "Name Manager". We have a range which defines our dataset - the "Refers To" field when defining a range can take a formula. So intead of giving it a fixed size, we use this: =OFFSET(Data!$A$1;0;0;COUNTA(Data!$A:$A);COUNTA(Data!$1:$1))
This counts the amount of rows and columns, with reference to A1 in our Data worksheet. All our pivots are set to reload on startup and that seems to work.

Read excel cell colour into Power BI

I have an excel file that I need to read into Power BI. Unfortunately I have no control over this file as its auto generated from another person.
Some of the cells in this file are just filled with colours and I want to be able to translate these colours when importing the data into Power BI.
For example if the colour is green in excel then show true in the corresponding power BI cell. At the moment it's just blank.
Does anyone know of a way to get cell "meta" data like colour from excel in Power BI?
Don't give up just yet...
I found an example that works in a roundabout way using Power Query in Excel. It will give you the meta data associated with each cell by its address (e.g. A1 is highlighted with color FFFFFF00). I relied on some Excel functions to associate the highlighted cell addresses with the cell values. Pulling the cell data with Power BI might take some additional work.
The technique is to use Power Query to open the Excel .xlsx file, which is basically a .zip file containing .xml documents. The color information for each cell can be extracted into a table. From there I was able to use INDIRECT() statements to read from the .xlsx workbook and extract the values from the colored cells. It worked quite well for me.
You can find a working example in the forum in the link below. The user defined DecompressFiles function in the sample uses the Binary.Decompress command to access the XML files within the .xlsx file.
https://www.excelguru.ca/forums/showthread.php?7047-Extract-Cell-Color-with-M&p=28875&viewfull=1#post28875
In my situation, I had a database export of about 7,000 rows and 50 columns into Excel. Working offline, users then went through Excel and made changes, highlighting every cell they had changed. Then they wanted me to update the database with only the highlighted cells. The background color used by each person varied but I didn't care what the color was, just that it was colored.
For each changed cell I was able to generate SQL statements to update the database and also insert into a transaction log table. The main database table was mostly flat but the few foreign key lookup values that were modified I had to update manually.
Column F uses the Indirect formula to pull data from the source workbook. Note that the source workbook must be open for the Indirect formula to read from it.
=INDIRECT("'[" & Import_Filename & "]" & Sheet_Name & "'!"&[#[SheetCellRef.2]])
Column G refines the data in Column F by putting quotes around strings or NULL if the cell is blank.
Column H grabs the column heading to know what field to update.
Column K grabs the Record ID value from the row specified in Column E.
I have had to run this process three different times for the users so my time invested paid off quickly. All I have to do is put their latest highlighted Excel file in the local folder and refresh the Power Query to generate new SQL statements.
Sorry I don't have a 'solution' posted right here. The process is still a little fragile and I'm trying to make a more robust example I can share. Stack Overflow doesn't seem to be set up for ongoing development of a solution. The point of this answer is to give hope to some of you who are desperate for a solution and won't take 'No' for an answer.
Sigh.
Color is not data. Unfortunately, many people color-code cells and then expect to be able to do things based on the color of the cell. But it's not that simple.
Although Excel now provides some ways to filter by cell color, it still cannot identify cell color with a worksheet formula.
Hence, you will need a VBA routine that evaluates all cells and records their colors in another table, which you will then need to push into your Power BI data model.
In the long run, it might be easier to talk to that other person who produces the color coded cells, and teach them a better way of doing things. Show them how to use conditional formatting based on cell values for color coding. The logic used for conditional formatting can also be applied to classify the data in Power BI.
From a data architecture point of view, the best solution is to address the problem at the source, instead of creating tools to handle bad data input.
Just sayin'.

how to setup a excel chart with data points

I have a excel spreadsheet that has been exported from a kendo-ui grid. I have zero experience with excel and I need help turning this data into a excel chart. the attached spreadsheet is what i am working with. Every subdivision name is its own series with (sqft,price) points. is there a way to make one chart with the supplied data?
attached is link to the excel spreadsheet
excel spreadsheet
update from first answer
First you need a table with just one header-row (create a new column for the Arbor .. Values).
The value of this column is the name for the diagram line (instead of serie1 etc.)

Resources