Jump to content

Excel formulae examples


randallc
 Share

Recommended Posts

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
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...