Jump to content

Recommended Posts

Posted

I am having an issue with _Excel_RangeReplace or maybe just with the whole loop I am trying to do.  I read a cell, If that cell = 77067 then Insert a row below that row, Copy the row to the inserted row.  Replace the search cell in the inserted row cell with 77063.

For $a = 1 To $iLastRow
    $aCell = _Excel_RangeRead($oWorkbook, Default, "D" & $a)
        If $aCell = "77067" Then
            $oWorkbook.ActiveSheet.Range($a +1&":"&$a +1).EntireRow.Insert
            _Excel_RangeCopyPaste($oWorkBook.Activesheet,  $a&":"&$a,  $a +1&":"&$a +1)
            _Excel_RangeReplace($oWorkBook, Default, "D:"&$a +1, 77067, 77063)
        EndIf
        Next

The _Excel_RangeReplace is giving an error code of 4  - $vRange is invalid.   Any help pointing me in the right direction would be Great.  Thank you

Posted

Nine,

           Thank you for your help.  That made the RangeReplace work but not exactly like I wanted it to.  It replaced All of the 77067 in the column when I just wanted that one cell replaced.  What am I doing wrong?

  • xcaliber13 changed the title to Excel RangeReplace Help(Solved)
Posted

Ok I figured it out.  With Nine's help on syntax  I figured out I needed to use RangeWrite.

_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "77063", "D"&$a +1)

in place of RangeReplace.

Again Thank you

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...