Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UpdateLinkedValue function not triggering recalculations for complex formulas #2008

Open
098anu098 opened this issue Oct 10, 2024 · 0 comments

Comments

@098anu098
Copy link

Description:
I'm using the excelize module to populate data into an Excel file and am subsequently calling the UpdateLinkedValue function to trigger recalculations for all formulas based on the newly populated data.

The issue arises with a specific formula that uses LOOKUP and TRANSPOSE to retrieve an entire row of data and convert it into a column. The formula looks like this:
TRANSPOSE( INDEX( INDIRECT("'"&SUBSTITUTE(MID(FORMULATEXT(A2),2,FIND("!",FORMULATEXT(A2))-2),"'","")&"'!"&MID(FORMULATEXT(A2),FIND("!",FORMULATEXT(A2))+1,LEN(FORMULATEXT(A2)))&":"& ADDRESS(ROW(INDIRECT(MID(FORMULATEXT(A2),FIND("!",FORMULATEXT(A2))+1,LEN(FORMULATEXT(A2))))), LOOKUP(2,1/(INDIRECT("'"&SUBSTITUTE(MID(FORMULATEXT(A2),2,FIND("!",FORMULATEXT(A2))-2),"'","")&"'!"&MID(FORMULATEXT(A2),FIND("!",FORMULATEXT(A2))+1,LEN(FORMULATEXT(A2)))&":"& ADDRESS(ROW(INDIRECT(MID(FORMULATEXT(A2),FIND("!",FORMULATEXT(A2))+1,LEN(FORMULATEXT(A2))))),1000))<>""),COLUMN(INDIRECT("'"&SUBSTITUTE(MID(FORMULATEXT(A2),2,FIND("!",FORMULATEXT(A2))-2),"'","")&"'!"&MID(FORMULATEXT(A2),FIND("!",FORMULATEXT(A2))+1,LEN(FORMULATEXT(A2)))&":"& ADDRESS(ROW(INDIRECT(MID(FORMULATEXT(A2),FIND("!",FORMULATEXT(A2))+1,LEN(FORMULATEXT(A2))))),1000)))) ) ), SEQUENCE(1,LOOKUP(2,1/(INDIRECT("'"&SUBSTITUTE(MID(FORMULATEXT(A2),2,FIND("!",FORMULATEXT(A2))-2),"'","")&"'!"&MID(FORMULATEXT(A2),FIND("!",FORMULATEXT(A2))+1,LEN(FORMULATEXT(A2)))&":"& ADDRESS(ROW(INDIRECT(MID(FORMULATEXT(A2),FIND("!",FORMULATEXT(A2))+1,LEN(FORMULATEXT(A2))))),1000))<>""), COLUMN(INDIRECT("'"&SUBSTITUTE(MID(FORMULATEXT(A2),2,FIND("!",FORMULATEXT(A2))-2),"'","")&"'!"&MID(FORMULATEXT(A2),FIND("!",FORMULATEXT(A2))+1,LEN(FORMULATEXT(A2)))&":"& ADDRESS(ROW(INDIRECT(MID(FORMULATEXT(A2),FIND("!",FORMULATEXT(A2))+1,LEN(FORMULATEXT(A2))))),1000))))-1 )))

I have applied this formula to one sheet where 5-6 columns are updated based on it. The workflow I'm using is:

  1. I populate data in the Excel file using excelize.
  2. I call UpdateLinkedValue to trigger recalculations.
  3. I open the Excel file to check the output.
    However, after running it through excelize, the cells using this formula show an "N/A" error. If I manually reapply the formula in the Excel UI, it recalculates correctly, but for some reason, the recalculations don't work automatically after the UpdateLinkedValue function is applied.

Expected Behavior:
Formulas should recalculate based on the populated data when UpdateLinkedValue is called, without needing to manually reapply them.

<style> </style>
Date Vectors Vectors        
Avaliação Econômica Financeira - Projeto (=) Gross Revenue (-) Production Cost A. O&M Cost Operating Cash Flow (FCO) Investing Cash Flow (CFI) Accumulated NPV
Avaliação Econômica Financeira - Projeto (=) Gross Revenue (-) Production Cost A. O&M Cost Operating Cash Flow (FCO) Investing Cash Flow (CFI) Accumulated NPV
0 0 0 0 -30.4382 0 -30.4382
0 0 0 0 -1.64101 -269 -282.812
0 0 0 0 -1.64101 -109 -372.528
0 0 0 0 -1.64101 0 -373.685
0 0 0 0 -1.64101 0 -374.691
2024 0 -30.43823022 -19.841 -1.64101 0 -375.566
2025 0 -1.641008 -1.64101 -1.64101 0 -376.327
2026 0 -1.641008 -1.64101 -1.64101 0 -376.989

Actual Behavior:
The cells return an "N/A" error after running the UpdateLinkedValue function. The formula only works when reapplied manually.

<style> </style>
Date Vectors Vectors      
Avaliação Econômica Financeira - Projeto (=) Gross Revenue (-) Production Cost Operating Cash Flow (FCO) Investing Cash Flow (CFI) Accumulated NPV
#N/A #N/A #N/A #N/A #N/A #N/A
#N/A #N/A #N/A #N/A #N/A #N/A
#N/A #N/A #N/A #N/A #N/A #N/A
#N/A #N/A #N/A #N/A #N/A #N/A
#N/A #N/A #N/A #N/A #N/A #N/A
#N/A #N/A #N/A #N/A #N/A #N/A
#N/A #N/A #N/A #N/A #N/A #N/A
#N/A #N/A #N/A #N/A #N/A #N/A

Environment:

Excelize version:"github.com/360EntSecGroup-Skylar/excelize"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@098anu098 and others