xcaliber13 Posted January 9, 2019 Posted January 9, 2019 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
Nine Posted January 9, 2019 Posted January 9, 2019 remove the : after the D “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
xcaliber13 Posted January 9, 2019 Author Posted January 9, 2019 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 Posted January 9, 2019 Author Posted January 9, 2019 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now