Jump to content

Recommended Posts

Posted

So I am rewriting most of my vbs scripts to AutoIt.   I am having a little trouble with this one.  Here is what works in vbs:

For i = 2000To1Step -1
     If objExcel.Range("C" & i).Value = objExcel.Range("N" & i).ValueThen objExcel.Rows(i).Delete
Next    

 Compares one cell to another and if = delete that row.

Here is what I have in AutoIt but it does not work.

For $i = 2000 To 1 Step -1
   If $oWorkbook.ActiveSheet.Range("C" & $i).Value = $oWorkbook.ActiveSheet.Range("N" & $i).Value Then $oWorkbook.ActiveSheet.Rows($i).Delete
Next

AutoIt script completes with no errors but no rows are deleted.   What am I missing?

  • Moderators
Posted

@xcaliber13 this is working for me:

#include <Excel.au3>
Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookOpen($oExcel, @DesktopDir & "\Test.xlsx")

    For $i = 50 To 1 Step -1
        If _Excel_RangeRead($oWorkbook, Default, "C" & $i) = _Excel_RangeRead($oWorkbook, Default, "N" & $i) Then
            $oExcel.Rows($i).Delete
        EndIf
    Next

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...