Jump to content

Little If Then problem with Exel


Recommended Posts

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
Link to comment
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
Link to comment
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

Link to comment
Share on other sites

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

edit:nevermind!

Edited by bchris01
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...