ThomasQ Posted July 24, 2009 Share Posted July 24, 2009 (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 July 24, 2009 by ThomasQ Link to comment Share on other sites More sharing options...
Beege Posted July 24, 2009 Share Posted July 24, 2009 "<>" 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 Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
ThomasQ Posted July 24, 2009 Author Share Posted July 24, 2009 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 More sharing options...
ThomasQ Posted July 24, 2009 Author Share Posted July 24, 2009 Got it, in: If $SpecialNo <> X Then, the X should be "X".. Thanks! Link to comment Share on other sites More sharing options...
Beege Posted July 24, 2009 Share Posted July 24, 2009 (edited) Its because of X. X needs to be a variable :$X or in quotes :"X". edit:nevermind! Edited July 24, 2009 by bchris01 Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator 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