Sign in to follow this  
Followers 0
randallc

Excel formulae examples

1 post in this topic

#1 ·  Posted (edited)

Hi,

Here shows how you can write any excel formula in a cell with ExcelCom, and return an answer.

[needs version 1_2_3 for new close and exit commands]

#include<ExcelCom.au3>

;needs version 1_2_3 for new close and exit commands

$FilePath=@ScriptDir&"\book1.xls"

If Not FileExists($FilePath) Or Not StringInStr($FilePath, "xls") Then

  $FilePath = FileOpenDialog("Go - Choose your excel file as inbuilt one not exists", $FilePath, "Worksheet" & " (" & "*.xls" & ")", 1)

EndIf

$Formula1="=roman(2005,1)"

$var1=_XLwrite($FilePath,3,"A",1,$Formula1)

$Formula2="=fact(12)"

$var2=_XLwrite($FilePath,3,"A",1,$Formula2)

$Formula3="=sin(radians(30))"

$var3=_XLwrite($FilePath,3,"A",1,$Formula3)

$Formula4="=power(2005,-1.3)"

$var4=_XLwrite($FilePath,3,"A",1,$Formula4)

$Formula5="=power(2005,1/3)"

$var5=_XLwrite($FilePath,3,"A",1,$Formula5)

_XLclose($FilePath,0); no changes and close workboot; not  Excel

msgbox (0,"_XLformula=", $Formula1&"="&$var1&@CRLF&$Formula2&"="&@tab&$var2&@CRLF&$Formula3&"="&@tab&$var3&@CRLF&$Formula4&"="&@tab&$var4&@CRLF&$Formula5&"="&@tab&$var5)

_XLread($FilePath,3,"A",1)

_XLexit($FilePath,0)

Best, Randall Edited by randallc

Share this post


Link to post
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
Sign in to follow this  
Followers 0