I have a Data Connection within my Excel Workbook (2007) which references a table within another Excel workbook. I have a cell that is referencing a date value within the last column header of the table. Each time the external workbook is updated and this date value changes, the cell reference in my workbook is broken and the cell shows #REF!
In case it helps I'm using a Database Query.
Connection string: {Replaced Path and Workbook Name}
DBQ=PATH\WORKBOOKNAME.xlsx;DefaultDir=PATH;Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DriverId=1046;FIL=excel 12.0;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;ReadOnly=1;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;
Command text: {Replaced Path}
SELECT * FROM `PATH\WORKBOOKNAME.xlsx`.`Main$` `Main$` ORDER BY `Main$`.IP
This is what the cell value in Column H looks like before the refresh:
This is what the cell value in Column H looks like after the refresh:
This last column header of this table contains a date value which will change each time the source workbook is updated (Volatile Date in source workbook). Technically this date field is not part of the other workbook table. However, the data connection is still pulling it and including it into the table on the main worksheet. I would not be able to modify the other workbook table and format without changing several other things due to other dependencies. I'm not sure of any other way to really reference a dynamic table header or correctly reference this cell so that the reference is not broken...
I'd like to do this within the cell formula without having to use a Macro if at all possible.
Any help is greatly appreciated. Thank You.
I guess the solution was as simple as using Indirect...
=INDIRECT("G1")
The header of the table should not change if you consider it used as a database field name. I can think a workaround as you directly give a range name to the date column in source book, for example, "Dates". Then in your other book, just make cells point to this range in source book, ie. make cells=[sourcebookname.xlsx]!Dates
Related
I have a simple Excel Table, named "Beta0" with two Columns "Date" and " Value". "Beta0" is created (and most importantly also updated) via a PowerQuery from a web page and is located in "Sheet1". The Power Query works all fine and updates the Table every Day, as it should. I now want to refer to the column "Value" from another sheet ("Sheet2") which also works:
"random_cell_in_sheet2" =Beta0[Value]
Excel then duplicates the whole column "Value" from "Sheet1" to "Sheet2" and more importantly, it updates the column in "Sheet2" when I update the "twin"-Column in "Sheet1". Dark magic kicks in, when i save the whole file. After reopening the file, the Code from above ist transferred from:
"random_cell_in_sheet2" = Beta0[Value]
to
"random_cell_in_sheet2" {=Sheet1!A3:A5881}
This Code will not update anything that I type in the "Value" from "Sheet1".
Is there something wrong with my Settings, that it doesn't save my my Structured Table Reference in the first Place? Can you please help me?
Found the solution! Was using an very old sheet (originated in the 1996s!). After updating the sheet, everything worked as it should :)
I have vlookups to pull specific data from a workbook and paste into a new workbook in the desired layout. The layout of the first workbook never changes however the name will change when i want to run this on a different file.
My current formula is =VLOOKUP(A3,[Workbook1.xlsx]Sheet1!$B$3:$XFD$7,2,FALSE)
I would really like it to reference A1 instead of Workbook1 so I could then just update the file name in A1 every time I want to analyse a different file. I should mention the Sheet name won't ever change.
I know you have to use INDIRECT but im unsure how it works. I did try =VLOOKUP(A3,INDIRECT(A1),$B$3:$XFD$7,2,FALSE) but then i'd too many arguments and when i removed the $B$3:$XFD$7 i lost the range i was searching in.
Thanks!
With INDIRECT you must create the whole string that denotes the range reference:
=VLOOKUP(A3,INDIRECT("'[" & A1 & "]Sheet1'!$B$3:$XFD$7"),2,FALSE)
One more note, that INDIRECT requires that the workbook be open to function, or will return an error.
A client has an exact template that must be used. Due to the formatting I cannot insert the data directly into the template via SSIS.
Idea:
Run SSIS as a schedule. It copies the template and populates the information.
I used a "reference" sheet in the same workbook to push all the necessary data to as I could not place it directly in the required template.
VLOOKUPs to the "reference" sheet are used to correctly set the data in the template.
Issue: The VLOOKUP does not automatically refresh the data. When I open the workbook the values are the same. If I change a cell in the reference table, the data updates in the VLOOKUPs.
Solution: What I need is a way to set the data in SSIS, and have the VLOOKUPs automatically re-check the data when the Excel workbook is opened.
Resolved
I have resolved the issue with the following
Issue
The VLOOKUPs will not update on open without manually opening/changing an impacted cell
=VLOOKUP(A1,Reference!$A2:$B6, 2, FALSE)
Solution Found
A bit of a hack, but in the Reference worksheet:
Added a "Format" row to the template
In the VLOOKUP reference column (Reference!$A2) place a formula that will be updated (e.g. "=TODAY()") in the "Format" row
Now whenever the workbook is opened, Reference!$A$2 is updated to today's date. This triggers the VLOOKUPs in the template to update because a value changed in the reference column. The full process is:
Template.xlsx (2 sheets: TemplateResults, and Reference)
SSIS - Copies Template.xlsx for current run
SSIS - Pulls data and places in Template.xlsx - Reference
Open CopiedTemplate.xlsx: Reference!$A$2 updates itself to current date. Triggers VLOOKUPs in TemplateResults to update themselves
I have made a connection in excel to another excel workbook, using the native functionality found under the data tab in excel. I imported the data into my "Main" excel workbook from the "Other" workbook by Selecting Data->existing connections and then opening the relevant sheet. This allowed me to link the data from my other workbook to my Main workbook.
My issue is when the data in the Other workbook is changed i received a #ref error in my Main workbook. The formulas i use on the imported data are pasted in a separate sheet (i tried pasting it next to the imported data as well). Note: i paste the formulas from row 1 - 500 for the respective column, so that when the data is imported the formula automatically populates the cell with the correct value. When i refresh the data (i.e when data has been changed in the Other workbook) It seems as the formulas i have copied down do not reference the correct cell anymore.
I have tried using an indirect but to no success.
This is what the formula i use looks like
=IF(INDIRECT("A"&ROW(#REF!))<>"",VLOOKUP(INDIRECT("A"&ROW(#REF!)),'Safex Codes'!$A$1:$H$1000,8,0),"")
However when the data is refreshed "SOME" of the rows in the column the formula is in return this formula
=IF(INDIRECT("A"&ROW(#REF!))<>"",VLOOKUP(INDIRECT("A"&ROW(#REF!)),'Safex Codes'!$A$1:$H$1000,8,0),"")
This occurs everytime i refresh the data. What is strange is that at the end of my data, hence the last time the formula is being called, the referencing to the correct row is completely off.
For example in row 28 i would expect the above formula to reference a28, however i receive
=IF(INDIRECT("A"&ROW(A24))<>"",VLOOKUP(INDIRECT("A"&ROW(A24))
I'll bet that you're having the same issue I was. When the number of rows in the data range changes, the unused cells previously populated with data are deleted. The formulas that referenced those deleted cells no longer have references to them because they've been deleted (hence the #REF errors).
You can change Excel's behavior with respect to handling new or unused rows using the Properties menu on the Data tab.
In that menu, take a look at the section labeled "If the number of rows in the data range changes upon refresh." I'm guessing you have the first option checked. Try the third option.
I am using XSSF to create a workbook and continually getting this error:
Excel found unreadable content in 'thefile'.xlsx. Do you want to recover the contents of this workbook? If you trust the source of the workbook click Yes.
Excel then obligingly recovers it by removing all of the data and gives the detail error report:
Removed Records: Cell information from /xl/worksheets/sheet1.xml part
I am following these principles:
Ensure the row is created and not null.
Ensure the cell is created and not null.
Ensure the cell is the correct type.
Write to cell.
Is there something I am missing, eg is it permissable to have only certain cells written to in a row eg:
|null|null|write something here|null|null|
and the same with rows:
row with content
null
row with content
or do I need to ensure the all rows and columns are filled blank through the ranges used.
This is a complete mystery.