Jump to content

_Excel_RangeWrite Formula with variable


Go to solution Solved by SkysLastChance,

Recommended Posts

I have been trying to figure this out longer then I would like to admit. I am betting that I am missing something super simple. 

#include <Excel.au3>

Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookNew($oExcel)

$vPath = "'J:\Temporary Files\FolderName\FileName.xlsx''!$A:$B,2,0))'"

 _Excel_RangeWrite($oWorkBook, Default, '=IF(D2=D1,"",VLOOKUP(D2,''J:\Temporary Files\FolderName\FileName.xlsx''!$A:$B,2,0))', "A1", False) ;Line 1
 _Excel_RangeWrite($oWorkBook, Default, '=IF(D2=D1,"",VLOOKUP(D2,' & $vPath, "A2", False) ;Line 2
 
ConsoleWrite("'=IF(D2=D1,"",VLOOKUP(D2,''J:\Temporary Files\FolderName\FileName.xlsx''!$A:$B,2,0))'" & @CRLF)
ConsoleWrite("'=IF(D2=D1,"",VLOOKUP(D2,'" & $vPath & @CRLF)

Why is line 1 writing but line 2 is not? 

Any suggestion to lead me in the right direction is appreciated. 

 

You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott

Link to comment
Share on other sites

  • Solution

Figured it out.

#include <Excel.au3>

Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookNew($oExcel)

$vPath = "'J:\Temporary Files\FolderName\FileName.xlsx'!$A:$B,2,0))"

_Excel_RangeWrite($oWorkBook, Default, '=IF(D2=D1,"",VLOOKUP(D2,''J:\Temporary Files\FolderName\FileName.xlsx''!$A:$B,2,0))', "A3", False) ;Line 1
_Excel_RangeWrite($oWorkBook, Default, '=IF(D2=D1,"",VLOOKUP(D2,' & $vPath, "A4", False) ;Line 2

 

You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...