T O P I C R E V I E W |
RandomOUser |
Posted - 06/15/2020 : 09:14:02 AM Hey Origin community,
I have a question concerning OriginPro 2020. In order to combine data from multiple workbooks and worksheets into a single sheet for further processing, I use cell formulas to access values.
As an example, I might type =[Book1]Sheet1!B1 into column A1 of a sheet to access cell B1 of Sheet1 in Book1.
In some cases, I would now like to "build" the references to different books and sheets using variables. As an example, I would like to replace Book1 in the aforementioned cell formula with a formula referencing a certain cell containing the corresponding workbook name as a string (let's say B3) in the active sheet. I tried subsituting Book1 with B3$ (obtaining =[B3$]Sheet1!B1 as a cell formula) / $(B3) / %(B3) / =B3$ etc. but nothing seems to work. I guess I don't understand the substitution notation correctly...
Can anyone help me?
Thank you for your help! |
4 L A T E S T R E P L I E S (Newest First) |
RandomOUser |
Posted - 06/15/2020 : 4:21:57 PM Thanks for your swift reply. Yes, this is exactly what I want to do. However, if I copy and paste =%([B2$]Sheet1, 2, 1) to an arbitrary cell (of course making sure that the book / sheet / cell referenced actually exist and having the value Book3 in cell B2), I only get an "unknown function" error and the cell contents is automatically changed to =%([B2$]Sheet1. 2. 1) for whatever reason. I use OriginPro 2020 (64-bit) SR1 9.7.0.188 (Academic) on Windows 10, if that helps. What does work, however, is using =[%(col(B)[2]$)]Sheet1!A1 instead. I have no idea why your code doesn't work. It would be much cleaner than my version.
quote: Originally posted by Chris D
Let's see if I understand it okay.
If this value is in the current worksheet in column B, row 2:
Book3
And I put this cell formula in the same sheet somewhere:
=%([B2$]Sheet1, 2, 1)
It will fill the cell with the value from Book3, Sheet1, column B, row 1.
Is that what you want?
Thanks, Chris Drozdowski Originlab Technical Support
|
Chris D |
Posted - 06/15/2020 : 1:19:26 PM Let's see if I understand it okay.
If this value is in the current worksheet in column B, row 2:
Book3
And I put this cell formula in the same sheet somewhere:
=%([B2$]Sheet1, 2, 1)
It will fill the cell with the value from Book3, Sheet1, column B, row 1.
Is that what you want?
Thanks, Chris Drozdowski Originlab Technical Support
|
RandomOUser |
Posted - 06/15/2020 : 12:24:53 PM First of all thank you for your help. Doesn't seem to work for some reason. If I enter your formula into an arbitrary cell after having defined the variable through the command window, all commas are replacedc by dots (might this have to do with european decimal point settings?) and I get no return value.
But anyways: If I understand you correctly, there is no way to achieve what I want without first defining a variable? I.e. it is not possible to avoid having to use separate scripts? That would be rather unfortunate because it would defeat the purpose of what I am triying to do. The idea is to extract book and sheet names from cell values without taking the detour of defining a variable.
Thanks again!
Edit: I have played around a bit and it seems that setting the cell formula to =[%(col(B)[3]$)]Sheet1!A1 does the trick. |
Chris D |
Posted - 06/15/2020 : 09:49:20 AM If you assign a global string variable:
string B3$ = "Book1";
try putting this in the cell formulae
=%([B3$]Sheet1, 2, 1)
Reference: https://www.originlab.com/doc/LabTalk/guide/Substitution-Notation#Worksheet_Column_and_Cell_Substitutionsubstitution.2C_worksheet_column.2Fcellworksheet.2C_column_and_cell_substitution
Thanks, Chris Drozdowski Originlab Technical Support
|
|
|