Hello,
I'm trying to set up a script that deletes a row in excel if it finds an L in a string of column 8. What i got is the following:
while>curRow%SCRIPT_DIR%\removeL,Sheet1,curRow,8,LorNotL
Label>same_row_again
if>LorNotL
XLDelRow>>%SCRIPT_DIR%\removeL,Sheet1,curRow
endif
Goto>same_row_again
Let>curRow=curRow+1
endwhile
what's missing is the condition: If the string in cell (curRow,8) contains an L, delete it. The string can look like this for example: "(G-8)(WQL 7)HRS 98)".
I'd be happy if you helped me, thank you.
Delete Excel row with string that contains letter L
Moderators: JRL, Dorian (MJT support)
Try this. Requires Macro Scheduler version 13.
Code: Select all
/// Set these three variables to your specifications ///
Let>file=%desktop_dir%\test1.xls
Let>Sheet=Sheet1
Let>StringToDetect=L
////////////////////////////////////////////////////////
XLOpen>file,0,XLhndl
XLGetSheetDims>XLhndl,Sheet,TotalRows,TotalCols
Let>kk=0
Repeat>kk
Add>kk,1
XLGetCell>XLhndl,Sheet,kk,8,cellContents
Separate>cellContents,StringToDetect,Lres
WriteLn>%temp_dir%xltest.txt,wres,%cellContents% - %kk%
If>Lres_count>1
WriteLn>%temp_dir%xltest.txt,wres,%cellContents% - %Lres_Count%
XLDelRow>XLhndl,Sheet,kk
//If you delete a row, be sure to set the row counter down one
Sub>kk,1
EndIf
Until>kk=TotalRows
XLSave>XLhndl,file
XLQuit>XLhndl