GianniD Posted October 26, 2009 Share Posted October 26, 2009 Hey everyone. I am trying to write a command to enter a formula into excel and have it contain a variable within it. Now since i'm new to AutoIt i may be doing this a very drawn out way but nonetheless it sort of works.This is my code:$var1=9Sleep(5000)While $var1 < 10Send("{ENTER}")Send("{F2}")Send("=6371.1*((2*ASIN(SQRT((SIN((RADIANS(Data!C"$var1")-RADIANS(Data!F2))/2)^2)+COS(RADIANS(Data!C"$var1"))*COS(RADIANS(Data!F2))*(SIN((RADIANS(Data!B"$var1")-RADIANS(Data!G2))/2)^2)))))*1000)")$var1=$var1+1WEndThe part where $var1 is is where i want to enter the variable but i keep getting an error. Could someone help me with the syntax?Thanks Link to comment Share on other sites More sharing options...
omikron48 Posted October 26, 2009 Share Posted October 26, 2009 (edited) It should be: Send("=6371.1*((2*ASIN(SQRT((SIN((RADIANS(Data!C" & $var1 & ")-RADIANS(Data!F2))/2)^2)+COS(RADIANS(Data!C" & $var1 & "))*COS(RADIANS(Data!F2))*(SIN((RADIANS(Data!B" & $var1 & ")-RADIANS(Data!G2))/2)^2)))))*1000)") If you need those double quotes to be part of the formula, it would be: Send('=6371.1*((2*ASIN(SQRT((SIN((RADIANS(Data!C"' & $var1 & '")-RADIANS(Data!F2))/2)^2)+COS(RADIANS(Data!C"' & $var1 & '"))*COS(RADIANS(Data!F2))*(SIN((RADIANS(Data!B"' & $var1 & '")-RADIANS(Data!G2))/2)^2)))))*1000)') Edited October 26, 2009 by omikron48 Link to comment Share on other sites More sharing options...
enaiman Posted October 26, 2009 Share Posted October 26, 2009 You keep forgetting the & - that's why you get the error.Send("=6371.1*((2*ASIN(SQRT((SIN((RADIANS(Data!C"&$var1&")-RADIANS(Data!F2))/2)^2)+COS(RADIANS(Data!C" SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now