NassauSky Posted February 17 Share Posted February 17 (edited) Yep, that's an odd subject and you'll understand more after trying the code below. Basically I'm loading a spreadsheet to an array variable during some changes to the sheet but the 2nd time I run the command it does not return an array. expandcollapse popup#include <Excel.au3> $sFullRange = "A1:L100" $sFileOpenDialogM = @ScriptDir & "\RefQuestions.xlsx" WinMinimizeAll ( ); or Send("#m") _Excel_GetSheetTotals() Func _Excel_GetSheetTotals() ;OPEN MAIN TEMPLATE FILE $prog_excel = _Excel_Open() If $prog_excel == 0 Then Exit $oWorkbookM = _Excel_BookOpen($prog_excel, $sFileOpenDialogM) ; If $oWorkbookM == 0 Then Msgbox("","Error", "Unable to open the specified excel file") Exit EndIf ;READ FULL SHEET VALUES TO ARRAY Local $read = _Excel_RangeRead($oWorkbookM, $oWorkbookM.Activesheet, $sFullRange, 1) $iIndexM = FindTotalRow($read) ;REMOVE BLANK ROWS FROM MAIN FILE (THEN ADD BLANK ROW) _Excel_RangeDelete($oWorkbookM.Activesheet, "A3:L" & ($iIndexM)) _Excel_RangeInsert($oWorkbookM.ActiveSheet, "3:3") ;RE-READ FULL SHEET VALUES TO ARRAY Local $read = _Excel_RangeRead($oWorkbookM, Default, "A1:L4", 1) ConsoleWrite("$read After deleting blank rows: " & $read & @CRLF) _ArrayDisplay($read,"After deleting blank rows") $iIndexM = FindTotalRow($read) MsgBox(0,"Notice","Application Doesn't Reach This Point: " & $iIndexM) EndFunc Func FindTotalRow($read) Local $iColtoSrch = 0 Local $sSearch = "TOTALS" Global $iIndex = _ArraySearch($read, $sSearch, 0, 0, 0, 1, 1, $iColtoSrch) If @error Then MsgBox($MB_SYSTEMMODAL, "Not Found So Exiting", '"' & $sSearch & '" was not found on column ' & $iColtoSrch & '.*') Exit EndIf Return $iIndex EndFunc RefQuestions.xlsx Edited February 17 by NassauSky Cleaning up verbiage Link to comment Share on other sites More sharing options...
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
Already have an account? Sign in here.Sign In Now