SkysLastChance

[SOLVED] Is it possible to skip a blank cell with my code?

4 posts in this topic

#1 ·  Posted (edited)

I was wondering if it is possible to make this code skip to the next row if it reads a blank line?

I tried this.

If $aArray = "" Then
       $r += 1
    EndIf
#include <Excel.au3>


Local $r = 1
    Local $aArray = _Excel_RangeRead($oWorkbook)
    ;~ If $iBox is greater than no. of rows in $aArray then $iBox equals the number of rows in $aArray
    If $iBox > (UBound($aArray) - 1) Then $iBox = UBound($aArray) - 1
    For $i = 1 To UBound($aArray) - 1   ;$i =0 Start from row A
    If $aArray = "" Then
        $r += 1
    EndIf
     
        $sR0  = $aArray[$i][0]    ;status
        $sR1  = $aArray[$i][1]    ;first name
        $sR2  = $aArray[$i][2]    ;Last name
        $sR3  = $aArray[$i][3]    ;Last 4 SSN
        $sR4  = $aArray[$i][4]    ;DOB
        $sR5  = $aArray[$i][5]    ;Email Address
        $sR6  = $aArray[$i][6]    ;Mailling Address
        $sR7  = $aArray[$i][7]    ;City
        $sR8  = $aArray[$i][8]    ;state
        $sR9  = $aArray[$i][9]    ;Zip Code
        $sR10 = $aArray[$i][10]   ;Gender
        $sR11 = $aArray[$i][11]   ;Phone

   WinSetState ("ADM.MCK - Registration Management Desktop","",@SW_MAXIMIZE)


      WinWaitActive("[CLASS:Notepad]", "", 10)

       ControlSend("[CLASS:Notepad]", "", "", ("{F8}"))
            Sleep (500)
        ControlSend("[CLASS:Notepad]", "", "", ("{F8}"))
            Sleep (500)
        ControlSend("[CLASS:Notepad]", "", "", ("N"))
        ControlSend("[CLASS:Notepad]", "", "", ("{TAB}"))
            Sleep (3000)
        ControlSend("[CLASS:Notepad]", "", "Edit1", $sR1 & @CR)
            Sleep (200)
        ControlSend("[CLASS:Notepad]", "", "", ("{TAB}"))
            Sleep (200)
        ControlSend("[CLASS:Notepad]", "", "Edit1", $sR2 & @CR)
            Sleep (200)
        ControlSend("[CLASS:Notepad]", "", "", ("{TAB}"))
            Sleep (200)
        ControlSend("[CLASS:Notepad]", "", "Edit1", $sR6& @CR)
            Sleep (200)
        ControlSend("[CLASS:Notepad]", "", "", ("{TAB}"))
            Sleep (200)
        ControlSend("[CLASS:Notepad]", "", "Edit1", $sR7 & @CR)
            Sleep (200)
        ControlSend("[CLASS:Notepad]", "", "Edit1", $sR8 & @CR)
            Sleep (200)
        ControlSend("[CLASS:Notepad]", "", "Edit1", $sR9 & @CR)
            Sleep (200)
        ControlSend("[CLASS:Notepad]", "", "Edit1", $sR11& @CR)
            Sleep (200)
        ControlSend("[CLASS:Notepad]", "", "Edit1", $sR5 & @CR) ;Email
            Sleep (200)
        ControlSend("[CLASS:Notepad]", "", "Edit1", $sR5 & @CR)  ;Email
            Sleep (200)
        ControlSend("[CLASS:Notepad]", "", "", (FormatDate($sR4) & @CR))


      $r += 1

 

 

Edited by SkysLastChance

Life's simple. You make choices and you don't look back.

Share this post


Link to post
Share on other sites



You would need to use the instance for example If $aArray[$i] = '' Then Continueloop

1 person likes this

Share this post


Link to post
Share on other sites
Func Auto ()
    Local $r = 1
    Local $aArray = _Excel_RangeRead($oWorkbook)
    ;~ If $iBox is greater than no. of rows in $aArray then $iBox equals the number of rows in $aArray
    If $iBox > (UBound($aArray) - 1) Then $iBox = UBound($aArray) - 1
    For $i = 1 To UBound($aArray) - 1   ;$i =0 Start from row A
    If $aArray[$i][1] = "" Then Continueloop

        $sR0  = $aArray[$i][0]    ;status
        $sR1  = $aArray[$i][1]    ;first name
        $sR2  = $aArray[$i][2]    ;Last name
        $sR3  = $aArray[$i][3]    ;Last 4 SSN
        $sR4  = $aArray[$i][4]    ;DOB
        $sR5  = $aArray[$i][5]    ;Email Address
        $sR6  = $aArray[$i][6]    ;Mailling Address
        $sR7  = $aArray[$i][7]    ;City
        $sR8  = $aArray[$i][8]    ;state
        $sR9  = $aArray[$i][9]    ;Zip Code
        $sR10 = $aArray[$i][10]   ;Gender
        $sR11 = $aArray[$i][11]   ;Phone

This worked for me thank you!


Life's simple. You make choices and you don't look back.

Share this post


Link to post
Share on other sites

Sorry should have realized it was a 2d array, Glad you got it working.

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

  • Similar Content

    • rootx
      By rootx
      I write this script to compare to array, well Do you have a better way to do it?
      #include <Constants.au3> #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> $a = FileSelectFolder("seleziona cartella A",@ScriptDir) $fold_A = _FileListToArrayRec($a,"*",2,1,0,1) $b = FileSelectFolder("seleziona cartella B",@ScriptDir) $fold_B = _FileListToArrayRec($b,"*",2,1,0,1) $tota = UBound($fold_A)-1 $totb = UBound($fold_B)-1 If $tota > $totb Then findx($fold_A,$fold_B) Else findx($fold_B,$fold_A) EndIf Func findx($min,$max) For $i = 0 To UBound($min)-1 $found = _ArraySearch($max, $min[$i]) If $found = -1 Then ConsoleWrite($min[$i]&@CRLF) EndIf Next EndFunc  
    • LoneWolf_2106
      By LoneWolf_2106
      Hi everybody,
      i have to store an entire row of a Excel workbook into an array.  The row index is stored in a variable.
      How can i do it?
      Thanks in advance for your support.
    • LoneWolf_2106
      By LoneWolf_2106
      Hi everybody,
      i have to write a value into an excel column.
      I know where it starts from, but i don't know what the end is, last non-empty cell.
      How can i get the number of last non-empty cell?
      Thanks in advance.
      Regards 
    • Jibberish
      By Jibberish
      I am trying to add data to an array and I keep getting the error "Subscript used on non-accessible variable ".
      #include <array.au3> ; Includes, etc ~ ~ ~ Local $aOptionsArray[3] $aOptionsArray = CheckboxesAndRadioButtons() _ArrayDisplay($aOptionsArray) Func CheckboxesAndRadioButtons() ; Create Checkboxes and Radio Buttons and read the results ~ ~ ~ ; Radio Buttons to Array ; $aOptions[0] = $bTestSelectForever ; $aOptions[1] = $bTestSelect3Times ; $aOptions[2] = $bTestSelectOnce If $bSelect1 = 1 Then $aOptions[0] = "True" Else $aOptions[0] = "False" <<< This is where the error occurs. EndIf If $bSelect2 = 1 Then $aOptions[1] = "True" Else $aOptions[1] = "False" EndIf If $bSelect3 = 1 Then $aOptions[2] = "True" Else $aOptions[2] = "False" EndIf Return $aOptions EndFunc Is putting data into an array while in a If - Then - Else illegal?
    • Nareshm
      By Nareshm
      Hi All,
      I have excel file like this
      and i want to cut cell/text from excel to other software.

       
      I have to cut the cell of B column one by one and past into other software
      If Winexists("No Data Found")
      then restore cuted cell and goto next/down side cell
      How to do it ?