Jump to content
SkysLastChance

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

Recommended Posts

SkysLastChance

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
Subz

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

  • Like 1

Share this post


Link to post
Share on other sites
SkysLastChance
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
Subz

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

    • Skeletor
      By Skeletor
      Hi Virtual People,
      My array works perfectly fine. However, what is the best practice if the line in the array doesn't have the correct amount of columns and if I can add a placeholder?

       
      For $count = 1 To _FileCountLines($FileRead1) Step 1 $string = FileReadLine($FileRead1, $count) $input = StringSplit($string, ",", 1) $value1 = $input[1] $value2 = $input[2] $value3 = $input[3] _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value2, "A1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value1, "B1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value3, "C1") Next  
    • Skeletor
      By Skeletor
      Hi Guys,
      Can anyone point me in the right direction. I'm trying to accomplished conditional formatting with arrows, but the code I have is wrong... 
      .Range("=$A3:$A4000").FormatConditions.Add = (xlCellValue, xlGreater, "=$A:$A") .IconSet(xl3Arrows) ;ActiveWorkbook.iconsets I also tried it like this:
      .Range("=$A3:$A4000").FormatConditions _ .Add(xlCellValue, xlGreater, "=$A:$A") .IconSet(xl3Arrows) ;ActiveWorkbook.iconsets  
    • MrCheese
      By MrCheese
      hi all,
      reviewing the forum, this thread is applicable: 
       
       
      I wanted to know if there is now a better way to do this?
      In essence, I load a tab delimited txt file into an array (works well). I used tab, as some fields in the original csv contains commas.
      However, I needed autoit to manipulate this array, and output it as a csv.
      IF my array contains items with a comma, without double quotes around the field, then how best do I get a csv out of this?
      My current workaround is to filewritefromarray tab delimited, then open it in excel and save as a csv. I will need to check this to see how the address fields behave that contain a comma.
       
      Any thoughts would be appreciated.
       
    • Skeletor
      By Skeletor
      Hi Guys,
      How would you use _Excel_FilterSet to filter the excel sheet from largest number to smallest number?
      _Excel_FilterSet($oWorkbook, "Sheet1", "A2:I2", 1, ">20", 1, "<40") ; OR _Excel_FilterSet($oWorkbook, "Sheet1", "A2:I2", 1, ">", 1, "<") Excel Sheet attached. Trying to filter on the last column "I2"
      Inventory.xlsx
    • Skeletor
      By Skeletor
      Hi All,
      Has anyone come across this before?
      Code below:
      $SheetList = _Excel_SheetList($oWorkbook) _FileWriteFromArray("C:\" & $SheetListOutput, $SheetList, 1) Result:
      ResultABC| ResultDEF| ResultGHI| ResultJKL| ResultMNO| It created these "|" vertical bars?
×