Sign in to follow this  
Followers 0
ThomasQ

Little If Then problem with Exel

5 posts in this topic

#1 ·  Posted (edited)

Hi!

I'm making a script to automaticly copy cells from excel to a form. I stumbled into a problem with the If Then function. In the N10 cell of my sheet there is either an X, wich means the $Specials don't need to be read, or its nothing, & then they do need to be read. How do I fix my script?

Thanks in advance!

#include <excel.au3>

$oExcel = _ExcelBookOpen("C:\Documents and Settings\Admin\Desktop\Projects\TestCleanSheet.xls",1,True)

$val = _ExcelReadCell($oExcel, "D5")

$Vrij = _ExcelReadCell($oExcel, "A11")

$SpecialNo = _ExcelReadCell($oExcel, "N10")

If $SpecialNo = X Then not

$Special1 = _ExcelReadCell($oExcel, "C19")

$Special2 = _ExcelReadCell($oExcel, "C20")

$Special3 = _ExcelReadCell($oExcel, "C21")

$Special4 = _ExcelReadCell($oExcel, "C22")

$Special5 = _ExcelReadCell($oExcel, "C23")

$Special6 = _ExcelReadCell($oExcel, "D19")

$Special7 = _ExcelReadCell($oExcel, "D20")

$Special8 = _ExcelReadCell($oExcel, "D21")

$Special9 = _ExcelReadCell($oExcel, "D22")

$Special10 = _ExcelReadCell($oExcel, "D23")

Edited by ThomasQ

Share this post


Link to post
Share on other sites



"<>" is another way of saying not equal to. Try this:

If $SpecialNo <> X Then
$Special1 = _ExcelReadCell($oExcel, "C19")
$Special2 = _ExcelReadCell($oExcel, "C20")
$Special3 = _ExcelReadCell($oExcel, "C21")
$Special4 = _ExcelReadCell($oExcel, "C22")
$Special5 = _ExcelReadCell($oExcel, "C23")
$Special6 = _ExcelReadCell($oExcel, "D19")
$Special7 = _ExcelReadCell($oExcel, "D20")
$Special8 = _ExcelReadCell($oExcel, "D21")
$Special9 = _ExcelReadCell($oExcel, "D22")
$Special10 = _ExcelReadCell($oExcel, "D23") 
endif

Share this post


Link to post
Share on other sites

Many Thanks! Still getting a syntax error on the If $SpecialNo <> X Then. Script works without the If & Then. Any suggestions?

I've broken the code down to something smaller:

#include <excel.au3>

$oExcel = _ExcelBookOpen("C:\Documents and Settings\Q\Desktop\Projects\INdat\TestCleanSheet.xls",1,True)

$oExcel2 = _ExcelBookOpen("C:\Documents and Settings\Q\Desktop\Projects\INdat\CleanSheet.xls",1,False)

$val = _ExcelReadCell($oExcel, "D5")

$Vrij = _ExcelReadCell($oExcel, "A11")

$SpecialNo = _ExcelReadCell($oExcel, "N10")

If $SpecialNo <> X Then

$Vrij =_ExcelWriteCell($oExcel2, $vrij, "C11")

endif

Share this post


Link to post
Share on other sites

Got it, in: If $SpecialNo <> X Then, the X should be "X".. Thanks!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Its because of X. X needs to be a variable :$X or in quotes :"X".

edit:nevermind!

Edited by bchris01

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